> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sevalla.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These are the docs for Sevalla, a platform for deploying applications, databases, static sites, object storage and load balancers. The dashboard is at https://app.sevalla.com.
> Bold text in steps is an exact dashboard label.
> To act on a Sevalla account, prefer the Sevalla MCP server (https://mcp.sevalla.com/mcp, see https://docs.sevalla.com/ai-agents/overview.md), then the Sevalla CLI (https://docs.sevalla.com/developer-tools/cli.md), then the REST API (https://api-docs.sevalla.com, OpenAPI spec at https://api.sevalla.com/v3/openapi.json).
> Every page index is at https://docs.sevalla.com/llms.txt.

# Deploy Python applications

> How Python web applications build and run on Sevalla: Python detection and versions, the PORT variable, processes for web servers, workers and migrations, and the framework guides.

A Python web application runs on Sevalla as an [application](/applications/overview): Sevalla builds an image from your Git repository, then runs it as processes. The web process serves HTTP with a production server such as Gunicorn or Uvicorn, background workers run task queues such as Celery, and jobs run migrations before each deployment.

## Framework guides

<Columns cols={3}>
  <Card title="Django" icon="layers" href="/guides/python/django/overview">
    Deploy Django, then add object storage, caching, async views, Celery, health checks and multitenancy.
  </Card>

  <Card title="FastAPI" icon="zap" href="/guides/python/fastapi/overview">
    Deploy FastAPI with SQLModel and Alembic, then add object storage, caching, Celery and health checks.
  </Card>

  <Card title="Flask" icon="flask-conical" href="/guides/python/flask/overview">
    Deploy Flask with an application factory, then add caching, Celery and health checks.
  </Card>
</Columns>

Moving from Heroku? See [Migrate from Heroku](/guides/migrate-from-heroku).

## How Python applications run on Sevalla

| Part | On Sevalla |
| - | - |
| Build | [Nixpacks](/applications/builds/nixpacks) 1.41 by default. It detects Python from `requirements.txt`, `pyproject.toml`, `Pipfile` or `main.py`, and installs the dependencies into a virtual environment at `/opt/venv`, which is on the `PATH`. |
| Package managers | pip with `requirements.txt`, Poetry with `poetry.lock`, PDM with `pdm.lock`, uv with `uv.lock`, Pipenv with `Pipfile` |
| Python version | Set in `.python-version` (for example `3.13`), `runtime.txt` or the `NIXPACKS_PYTHON_VERSION` environment variable. Nixpacks 1.41 supports versions up to 3.13. Pin the version: Django 6.1, for example, needs 3.12 or later. |
| Web server | A production server such as Gunicorn (WSGI) or Uvicorn (ASGI), listening on `0.0.0.0` and the port in the `PORT` environment variable. Sevalla sets `PORT` to the web process's port, `8080` by default. |
| Start command | `[start]` in `nixpacks.toml`, or the **Custom start command** of a process on the **Processes** tab. Without either, Nixpacks runs `python manage.py migrate && gunicorn <project>.wsgi` for Django and `python main.py` when there's a `main.py`. |
| Migrations | A job with the start policy **Before deployment**. If it fails, the deployment fails and the previous version keeps running. |
| Task queues | A background worker, for example `celery -A storefront worker`. |
| Scheduled tasks | A cron job, for example `python manage.py clearsessions` every night. |
| Databases | PostgreSQL, MySQL, MariaDB, Redis or Valkey on Sevalla, reached over an [internal connection](/databases/connect#connect-an-application) that adds the connection details as environment variables. |
| Files | The filesystem resets on every deployment. Keep uploads in [object storage](/object-storage/overview), or attach a [disk](/applications/disks). |
| Other build strategies | [Railpack](/applications/builds/railpack), [Buildpacks](/applications/builds/buildpacks) and [Dockerfile](/applications/builds/dockerfile), on the application's **Settings** tab |

See [Processes](/applications/processes) for every process type and its settings.

## Connection variables

When you add an internal connection and turn on **Add environment variables to the application**, Sevalla adds these variables (see [Environment variables an internal connection adds](/databases/connect#environment-variables-an-internal-connection-adds)). You can rename them in the same sheet before you save, for example `DB_URL` to `DATABASE_URL`.

| Database | Variables | URL format |
| - | - | - |
| PostgreSQL | `DB_HOST`, `DB_PORT`, `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD`, `DB_URL` | `postgres://<user>:<password>@<host>:<port>/<database>` |
| MySQL, MariaDB | The same six variables | `mysql://<user>:<password>@<host>:<port>/<database>` |
| Redis | `REDIS_HOST`, `REDIS_PORT`, `REDIS_PASSWORD`, `REDIS_URL` | `redis://:<password>@<host>:<port>/0` |
| Valkey | The same four variables | `valkey://:<password>@<host>:<port>/0` |

Two schemes need care in Python:

* SQLAlchemy (and so SQLModel, Flask-SQLAlchemy-Lite and Alembic) doesn't accept `postgres://`. Replace it with `postgresql+psycopg://` in code. Django's database URL parsers accept it as is.
* redis-py, Celery and Django's Redis cache accept `redis://`, `rediss://` and `unix://` only. With a Valkey database, replace `valkey://` with `redis://`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.