R
Railway•10mo ago
Beep

Deploying issue: Python Flask server

Hi, first off thank you for helping, I have been trying to sort this most of the day 😄 I have a Flask server written in python that is running fine locally in VSCode, but when I try to run it with railway it is failing. The deploy logs are showing:
Traceback (most recent call last):

File "main.py", line 2, in <module>

from logic.reqs import getArtists, getArtistInfo, updateCookie

File "/app/logic/reqs.py", line 12, in <module>

def fetchCookie() -> str | bool:

TypeError: unsupported operand type(s) for |: 'type' and 'type'

Traceback (most recent call last):
Traceback (most recent call last):

File "main.py", line 2, in <module>

from logic.reqs import getArtists, getArtistInfo, updateCookie

File "/app/logic/reqs.py", line 12, in <module>

def fetchCookie() -> str | bool:

TypeError: unsupported operand type(s) for |: 'type' and 'type'

Traceback (most recent call last):
But I am completely unsure why or where the issue is based on this. Any help at all would be the best for me thank you again
No description
Solution:
set your start command to gunicorn main:app
Jump to solution
28 Replies
Percy
Percy•10mo ago
Project ID: N/A
Beep
BeepOP•10mo ago
direful-jewel
Brody
Brody•10mo ago
what version of python are you using locally
Beep
BeepOP•10mo ago
Hi! 3.10.6 in VScode
Brody
Brody•10mo ago
what version is railway using
Beep
BeepOP•10mo ago
Where can I see that sorry? I just removed all my return type annotation -> bool ect and its running now 🤔 maybe that was it! But when I make a request the public url on railway im getting 301 so maybe its still broken
Brody
Brody•10mo ago
at the top of the build logs
Beep
BeepOP•10mo ago
Ah yes, python 3.8
Brody
Brody•10mo ago
add a runtime.txt to your project with 3.10 in it
Beep
BeepOP•10mo ago
Okay yep now its on 3.10 But still getting 301 when I try to access the server 🤔
Brody
Brody•10mo ago
that's a redirect, are you sure you are using https
Beep
BeepOP•10mo ago
My bad sorry! I now get 503 with https://
Brody
Brody•10mo ago
what's your current start command
Beep
BeepOP•10mo ago
For my python code?
Brody
Brody•10mo ago
the start command in use by railway
Beep
BeepOP•10mo ago
I havent set one so I think its just using main.py
Brody
Brody•10mo ago
please check
Beep
BeepOP•10mo ago
Okay I set it to "python main.py" The deloy logs have
* Serving Flask app 'main'

* Debug mode: on

WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

* Running on http://127.0.0.1:5000

Press CTRL+C to quit

* Restarting with stat

* Debugger is active!

* Debugger PIN: 731-532-096
* Serving Flask app 'main'

* Debug mode: on

WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.

* Running on http://127.0.0.1:5000

Press CTRL+C to quit

* Restarting with stat

* Debugger is active!

* Debugger PIN: 731-532-096
But still 503 for /cookies for example as well as all end points on my Flask server 🤔
Brody
Brody•10mo ago
you are running a development server
Solution
Brody
Brody•10mo ago
set your start command to gunicorn main:app
Beep
BeepOP•10mo ago
Done but same outcome Is it becuase its a flask server railway cant use it?
Brody
Brody•10mo ago
show me your deploy logs now please oh shit this is flask lol, for some reason I thought this was fastapi
Beep
BeepOP•10mo ago
/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found
/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found

/bin/bash: line 1: uvicorn: command not found
Is that better than flask? Happy to swap 🤣
Brody
Brody•10mo ago
fixed, but make sure you have gunicorn in your requirements.txt
Beep
BeepOP•10mo ago
Okay different logs
[2024-02-07 17:07:56 +0000] [7] [INFO] Starting gunicorn 21.2.0

[2024-02-07 17:07:56 +0000] [7] [INFO] Listening at: http://0.0.0.0:7109 (7)

[2024-02-07 17:07:56 +0000] [7] [INFO] Using worker: sync

[2024-02-07 17:07:56 +0000] [10] [INFO] Booting worker with pid: 10
[2024-02-07 17:07:56 +0000] [7] [INFO] Starting gunicorn 21.2.0

[2024-02-07 17:07:56 +0000] [7] [INFO] Listening at: http://0.0.0.0:7109 (7)

[2024-02-07 17:07:56 +0000] [7] [INFO] Using worker: sync

[2024-02-07 17:07:56 +0000] [10] [INFO] Booting worker with pid: 10
omg it worked omg thank you so much Brody!!!
Brody
Brody•10mo ago
awesome happy to help
Beep
BeepOP•10mo ago
This is awesome thank you so much Really really great help
Brody
Brody•10mo ago
thanks 🙂
Want results from more Discord servers?
Add your server