# Deploy Python

Any Python web app runs as a container on the Python runtime - the same machinery behind the [Django](/platform/frameworks/django), [FastAPI](/platform/frameworks/fastapi), and [Flask](/platform/frameworks/flask) guides, available to every other Python server too. Detection reads your dependency manifest; the default port is `8000`.

## The contract

- **Bind `0.0.0.0`**, not `127.0.0.1` - traffic is routed into the container from outside.
- **Listen on the routed [port](/create/build-settings#port)**, or read `PORT` from the environment, which is set to it.
- **Log to stdout/stderr** - that is what lands in [runtime logs](/platform/observability#runtime-logs).

```bash
uvicorn app:app --host 0.0.0.0 --port $PORT     # ASGI
gunicorn app:app --bind 0.0.0.0:$PORT           # WSGI
```

## Configuration and database

Containers receive [environment variables](/platform/environment-variables#build-time-and-runtime) at runtime - read `os.environ` at startup, never at image build. `DATABASE_URL` comes from the [Credentials tab](/platform/databases/connect); SQLAlchemy and most drivers take it directly.

## Scale to zero and workers

Python containers [scale to zero](/create/scaling#min-instances) like any other. Keep startup light, connect to the database lazily, and match [concurrency](/create/scaling#concurrency) to your server model - high for async, `10`-`20` for sync workers or CPU-heavy endpoints.

## Related

- [Django](/platform/frameworks/django): Settings, migrations, and static files.
- [FastAPI](/platform/frameworks/fastapi): Uvicorn and async concurrency.
- [Flask](/platform/frameworks/flask): Gunicorn and sync worker sizing.
- [Dockerfile](/platform/frameworks/docker): Take over the image when you need system packages.
