Flask not working

Anonymous
TRIAL

2 years 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

Anonymous
TRIAL

2 years ago

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


2 years ago

Dev server detected!


Anonymous
TRIAL

2 years ago

thats why?


2 years 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 )


Anonymous
TRIAL

2 years ago

alright let me try it


2 years ago

gunicorn main:app

will suffice in most cases


Anonymous
TRIAL

2 years ago

1225126887156748500


Anonymous
TRIAL

2 years ago

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


Anonymous
TRIAL

2 years ago

it worked


Anonymous
TRIAL

2 years ago

but


Anonymous
TRIAL

2 years ago

I have a discord bot


Anonymous
TRIAL

2 years ago

with it but its not loaded?



Anonymous
TRIAL

2 years ago

right here before it said discord logging in


2 years ago

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


Anonymous
TRIAL

2 years ago

because im hosting a dashboard with it also


Anonymous
TRIAL

2 years ago

and this will really help me out


2 years ago

you would need to start the discord bot in async mode


Anonymous
TRIAL

2 years ago

ah


Anonymous
TRIAL

2 years ago

I have it like this


Anonymous
TRIAL

2 years 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()```


Anonymous
TRIAL

2 years ago

how do i fix it?


2 years ago

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


Anonymous
TRIAL

2 years ago

ah okay


2 years ago

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


Anonymous
TRIAL

2 years ago

isnt it already


Anonymous
TRIAL

2 years ago

1225130113142882300


2 years ago

is the discord bot running?


Anonymous
TRIAL

2 years ago

nope


2 years ago

then my statement stands


Anonymous
TRIAL

2 years ago

okay


Anonymous
TRIAL

2 years ago

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


2 years ago

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


Anonymous
TRIAL

2 years ago

yea i see why now


Anonymous
TRIAL

2 years ago

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


2 years ago

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


Anonymous
TRIAL

2 years ago

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


2 years ago

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


Anonymous
TRIAL

2 years ago

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


2 years ago

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