Documentation

guides

Deploy a Python App

Deploy Flask, FastAPI, Django, or any Python application to Runix.

Python apps deploy beautifully on Runix. Whether you're building a FastAPI microservice, a Django web app, a Flask API, or a custom Python server, Runix detects your setup and deploys it automatically.

Prerequisites#

  • A Python project with a requirements.txt or pyproject.toml file
  • A Runix account (sign up free at runixcloud.dev)

Supported Frameworks#

FrameworkAuto-DetectedNotes
FastAPIYesModern, fast async framework
FlaskYesLightweight and flexible
DjangoYesFull-featured web framework
Plain PythonYesAny HTTP server

Example: FastAPI App#

Here's a simple FastAPI project. If you already have a Python app with dependencies listed, you can skip ahead to the configuration step.

main.py
python
from fastapi import FastAPI
import os

app = FastAPI()

@app.get("/")
def read_root():
    return {"message": "Hello from Runix!"}

@app.get("/health")
def health():
    return {"status": "ok"}
requirements.txt
text
fastapi>=0.100.0
uvicorn[standard]>=0.23.0
gunicorn>=21.2.0

Make sure gunicorn is in your requirements.txt. Runix uses gunicorn as the production WSGI/ASGI server. Without it, your app may fail to start in production.

Configuration#

Run runix init and Runix will detect Python from your requirements.txt or pyproject.toml. Here's what the generated runix.yaml looks like:

runix.yaml
yaml
name: my-python-app
services:
  - name: api
    type: web-service
    repo: https://github.com/yourname/my-python-app
    branch: main
    env:
      PYTHONUNBUFFERED: "1"

How It Works#

  1. 1.Runix detects Python from requirements.txt or pyproject.toml
  2. 2.It identifies your framework (FastAPI, Flask, Django) from your dependencies
  3. 3.An AI-powered engine generates a production Dockerfile with the right Python version and server
  4. 4.Your app is built, containerized, and deployed with a public HTTPS URL

Environment Variables#

VariableSet ByDescription
PORTRunix (automatic)The port your app should listen on
PYTHONUNBUFFEREDRecommendedSet to "1" so logs appear in real time

Make sure your app reads the PORT environment variable. For FastAPI with uvicorn, you can do this:

main.py
python
import os
import uvicorn

if __name__ == "__main__":
    port = int(os.environ.get("PORT", 8000))
    uvicorn.run("main:app", host="0.0.0.0", port=port)

Django Apps#

For Django projects, make sure you have:

  • gunicorn in your requirements.txt
  • A wsgi.py file (Django creates this by default)
  • ALLOWED_HOSTS set to include your Runix domain (or use ["*"] for simplicity)
  • STATIC_ROOT configured if you serve static files
python
# settings.py
import os

ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "*").split(",")

STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")

Common Issues#

Missing gunicorn#

If your app builds but fails to start, the most common cause is gunicorn not being in your requirements.txt. Add it:

bash
# Add gunicorn to your requirements
echo "gunicorn>=21.2.0" >> requirements.txt

Using pyproject.toml instead of requirements.txt#

Runix supports both. If you use pyproject.toml, make sure your dependencies are listed under [project.dependencies] or in a [tool.poetry.dependencies] section. Runix reads both formats.