Deploy a Python application on onesubnet
Deploy Flask/Django/FastAPI in Python: dependencies, build/start command, port and environment variables.
Deploy a Python application on onesubnet
onesubnet runs your Python applications (Flask, Django, FastAPI, scripts, bots…). Deploy via Git from the panel.
1. Prepare the project
- List dependencies in
requirements.txt(orpyproject.toml). - Make your app listen on the port from the
PORTenvironment variable:
import os
port = int(os.environ.get("PORT", 8000))
app.run(host="0.0.0.0", port=port)
2. Deploy
- In the panel, connect your Git repository (or upload the code).
- Build command:
pip install -r requirements.txt - Start command (per framework):
- FastAPI:
uvicorn app:app --host 0.0.0.0 --port $PORT - Flask:
gunicorn app:app -b 0.0.0.0:$PORT - Django:
gunicorn myproject.wsgi -b 0.0.0.0:$PORT
- FastAPI:
3. Environment variables
Set DATABASE_URL, secrets, etc. in Settings → Environment in the panel.
4. Logs
Live console and log files in the panel to diagnose a startup crash.
References
- Python: https://docs.python.org/3/
- Gunicorn: https://docs.gunicorn.org/
- Uvicorn: https://www.uvicorn.org/