Flask not working

AnonymousTRIAL

a year ago

Hi I have my project and when I deploy it theres no errors but when i go onto the website where its being hosted I get server error but I have my app.run like this [app.run](app.run)(port=5000)

0 Replies

AnonymousTRIAL

a year ago

a456ed59-7ab2-4b5a-bfdf-4717e08317e9


a year ago

Dev server detected!


AnonymousTRIAL

a year ago

thats why?


a year ago

Your app needs to use 0.0.0.0 as the host ( like the message box at the top says )
You're also running a development server, you'll want to use gunicorn to run your server

to do that, add gunicorn to requirements.txt
your start command would look something like this gunicorn main:app -b [::]:5000
( you can set it in service settings )


AnonymousTRIAL

a year ago

alright let me try it


a year ago

gunicorn main:app

will suffice in most cases


AnonymousTRIAL

a year ago

1225126887156748500


AnonymousTRIAL

a year ago

so yea i did both of what you guys told me into my start command and it gives out this


AnonymousTRIAL

a year ago

it worked


AnonymousTRIAL

a year ago

but


AnonymousTRIAL

a year ago

I have a discord bot


AnonymousTRIAL

a year ago

with it but its not loaded?



AnonymousTRIAL

a year ago

right here before it said discord logging in


a year ago

a discord bot with a flask app? may i ask why?


AnonymousTRIAL

a year ago

because im hosting a dashboard with it also


AnonymousTRIAL

a year ago

and this will really help me out


a year ago

you would need to start the discord bot in async mode


AnonymousTRIAL

a year ago

ah


AnonymousTRIAL

a year ago

I have it like this


AnonymousTRIAL

a year ago

```def run_flask():
app.run(port=5000)

def run_discord():
bot.run(TOKEN)

if name == "main":
flaskthread = threading.Thread(target=runflask)
discordthread = threading.Thread(target=rundiscord)
flaskthread.start() discordthread.start()
flaskthread.join() discordthread.join()```


AnonymousTRIAL

a year ago

how do i fix it?


a year ago

Im sorry but we wouldnt be able to offer coding help here, these help threads are meant to provide platform help


AnonymousTRIAL

a year ago

ah okay


a year ago

get it working locally with gunicorn and then we can can pick back up on this


AnonymousTRIAL

a year ago

isnt it already


AnonymousTRIAL

a year ago

1225130113142882300


a year ago

is the discord bot running?


AnonymousTRIAL

a year ago

nope


a year ago

then my statement stands


AnonymousTRIAL

a year ago

okay


AnonymousTRIAL

a year ago

may you please help out, i still dont understand how gunicorn is blocking it


a year ago

Im sorry but we wouldnt be able to offer coding help here, these help threads are meant to provide platform help


AnonymousTRIAL

a year ago

yea i see why now


AnonymousTRIAL

a year ago

when i remove gunicorn main:app from the start command it goes back to dev and loads the discord bot


a year ago

you need to use gunicorn to run the flask app when on railway


AnonymousTRIAL

a year ago

do you know how i can allow the discord bot also?


a year ago

again, sorry but we would not be able to offer code help here


AnonymousTRIAL

a year ago

no im asking what else do i put on the start command


a year ago

nothing to do with the start command, this would be a code issue


Flask not working - Railway Help Station