R
Railway8mo ago
je

Flask not working

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(port=5000)
No description
31 Replies
Percy
Percy8mo ago
Project ID: a456ed59-7ab2-4b5a-bfdf-4717e08317e9
je
je8mo ago
a456ed59-7ab2-4b5a-bfdf-4717e08317e9
LaCrak27
LaCrak278mo ago
Dev server detected!
je
je8mo ago
thats why?
Fragly
Fragly8mo 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 )
je
je8mo ago
alright let me try it
Brody
Brody8mo ago
gunicorn main:app
gunicorn main:app
will suffice in most cases
je
je8mo ago
No description
je
je8mo ago
so yea i did both of what you guys told me into my start command and it gives out this it worked but I have a discord bot with it but its not loaded?
je
je8mo ago
right here before it said discord logging in
Brody
Brody8mo ago
a discord bot with a flask app? may i ask why?
je
je8mo ago
because im hosting a dashboard with it also and this will really help me out
Brody
Brody8mo ago
you would need to start the discord bot in async mode
je
je8mo ago
ah I have it like this
def run_flask():
app.run(port=5000)


def run_discord():
bot.run(TOKEN)

if __name__ == "__main__":
flask_thread = threading.Thread(target=run_flask)
discord_thread = threading.Thread(target=run_discord)
flask_thread.start()
discord_thread.start()
flask_thread.join()
discord_thread.join()
def run_flask():
app.run(port=5000)


def run_discord():
bot.run(TOKEN)

if __name__ == "__main__":
flask_thread = threading.Thread(target=run_flask)
discord_thread = threading.Thread(target=run_discord)
flask_thread.start()
discord_thread.start()
flask_thread.join()
discord_thread.join()
how do i fix it?
Brody
Brody8mo ago
Im sorry but we wouldnt be able to offer coding help here, these help threads are meant to provide platform help
je
je8mo ago
ah okay
Brody
Brody8mo ago
get it working locally with gunicorn and then we can can pick back up on this
je
je8mo ago
isnt it already
je
je8mo ago
No description
Brody
Brody8mo ago
is the discord bot running?
je
je8mo ago
nope
Brody
Brody8mo ago
then my statement stands
je
je8mo ago
okay may you please help out, i still dont understand how gunicorn is blocking it
Brody
Brody8mo ago
Im sorry but we wouldnt be able to offer coding help here, these help threads are meant to provide platform help
je
je8mo ago
yea i see why now when i remove gunicorn main:app from the start command it goes back to dev and loads the discord bot
Brody
Brody8mo ago
you need to use gunicorn to run the flask app when on railway
je
je8mo ago
do you know how i can allow the discord bot also?
Brody
Brody8mo ago
again, sorry but we would not be able to offer code help here
je
je8mo ago
no im asking what else do i put on the start command
Brody
Brody8mo ago
nothing to do with the start command, this would be a code issue
Want results from more Discord servers?
Add your server