R
Railway3mo 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
Percy3mo ago
Project ID: a456ed59-7ab2-4b5a-bfdf-4717e08317e9
je
je3mo ago
a456ed59-7ab2-4b5a-bfdf-4717e08317e9
LaCrak27
LaCrak273mo ago
Dev server detected!
je
je3mo ago
thats why?
Fragly
Fragly3mo 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
je3mo ago
alright let me try it
Brody
Brody3mo ago
gunicorn main:app
gunicorn main:app
will suffice in most cases
je
je3mo ago
No description
je
je3mo 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
je3mo ago
right here before it said discord logging in
Brody
Brody3mo ago
a discord bot with a flask app? may i ask why?
je
je3mo ago
because im hosting a dashboard with it also and this will really help me out
Brody
Brody3mo ago
you would need to start the discord bot in async mode
je
je3mo 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
Brody3mo ago
Im sorry but we wouldnt be able to offer coding help here, these help threads are meant to provide platform help
je
je3mo ago
ah okay
Brody
Brody3mo ago
get it working locally with gunicorn and then we can can pick back up on this
je
je3mo ago
isnt it already
je
je3mo ago
No description
Brody
Brody3mo ago
is the discord bot running?
je
je3mo ago
nope
Brody
Brody3mo ago
then my statement stands
je
je3mo ago
okay may you please help out, i still dont understand how gunicorn is blocking it
Brody
Brody3mo ago
Im sorry but we wouldnt be able to offer coding help here, these help threads are meant to provide platform help
je
je3mo 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
Brody3mo ago
you need to use gunicorn to run the flask app when on railway
je
je3mo ago
do you know how i can allow the discord bot also?
Brody
Brody3mo ago
again, sorry but we would not be able to offer code help here
je
je3mo ago
no im asking what else do i put on the start command
Brody
Brody3mo ago
nothing to do with the start command, this would be a code issue