Skip to content
Pages in Guides

Python frameworks

Django, Flask and FastAPI: the virtual environment, the server that runs them and their static files.

Guide Updated View as Markdown

Part of Deploying by framework.

Python projects are detected by requirements.txt, pyproject.toml, setup.py or Pipfile. Noust builds a virtual environment (Poetry or Pipenv when the project is locked with them) and runs Gunicorn on 127.0.0.1, with Uvicorn workers for FastAPI and Starlette (Hypercorn when the project depends on it). Pin the interpreter with runtime: python@3.12.

Django

Shell
noust create -d site.example.com -s https://github.com/you/site.git

The project's own wsgi.py or asgi.py is found; collectstatic runs when the settings define a STATIC_ROOT (and Noust serves it); put the migration in a hook:

YAML
hooks:
  pre_deploy:
    - run: python manage.py migrate --noinput
      migrates: true

Add the domain to ALLOWED_HOSTS (Noust does not guess it), and keep SECRET_KEY and the database URL in .env.

Flask and FastAPI

Noust's default start is gunicorn app:app -b 127.0.0.1:PORT, with Uvicorn workers for an ASGI application (FastAPI, Starlette). If the application object is not app in app.py, say what to run with start: in the build: block (PORT is in the environment):

YAML
build:
  start: gunicorn -b 127.0.0.1:${PORT} -k uvicorn.workers.UvicornWorker app.main:app

Something on this page is wrong or unclear? Report it on GitHub.

Help, contributing and the project’s policies are under Project.

Search the documentation

Type to search every page.

↑ ↓ to move, Enter to open, Esc to close