Deploying Flask API for my frontend application
ahmed-jan-farooqui
TRIALOP

2 years ago

I have a Flask based server which runs some critical tasks such as querying an LLM with Retrieval Augmented Generation. The results of this are used by my frontend application. To run this server on my local host, I simply run "python3 .py". However, the build for this fails when I try to deploy it with the error:
Start command not found
originating from Nixpacks.
I cannot find how to configure this start command anywhere. Help is appreciated.
For context, the github repo structure looks like:
--> server.py
--> requirements.txt
--> firebase-admin-creds.json
--> GPTAPIkey.txt

View Deploy details

> ⓘ Deployment information is only viewable by Project members and Railway admins.

5 Replies

brody
EMPLOYEE

2 years ago

This is a flask app, meaning you need to run it with gunicorn when on Railway, otherwise you are going to be running a very costly and very fragile development server.

You can specify your start command in a railway.json file as shown here -

https://github.com/railwayapp-templates/flask/blob/main/railway.json

The template has a main.py file and you have a server.py file, so you will need to slightly tweak the start command, but hopefully that gets you going.


ahmed-jan-farooqui
TRIALOP

2 years ago

Thank you. I was able to deploy it successfully using gunicorn like you mentioned.


brody
EMPLOYEE

2 years ago

Awsome!


venturero
FREE

a month ago

I used the same ending as yours. However, my code didn't deploy on Railway. Why is that?
app.run(debug=True, port=os.getenv("PORT", default=5000))
I got the following log output:
Starting Container

* 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:8080

Press CTRL+C to quit

* Restarting with stat

* Debugger is active!

* Debugger PIN: 118-674-401

@ahmed-jan-farooqui


venturero

I used the same ending as yours. However, my code didn't deploy on Railway. Why is that?app.run(debug=True, port=os.getenv("PORT", default=5000))I got the following log output:Starting Container* Serving Flask app 'main'* Debug mode: onWARNING: 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:8080Press CTRL+C to quit* Restarting with stat* Debugger is active!* Debugger PIN: 118-674-401@ahmed-jan-farooqui

venturero
FREE

a month ago

@brody


Loading...