DockHostingDocs
Stacks

Python

Deploy Django, Flask, FastAPI, Streamlit or any Python web app.

What we detect

requirements.txt, pyproject.toml or a Pipfile makes it a Python app. We recognise Streamlit, Django, Flask and FastAPI from your dependencies. The default port is 5000.

The most important setting is the start command: a production server listening on 0.0.0.0:$PORT. Set it in the project's Settings, or in a Procfile.

Flask

Don't deploy with app.run(debug=True)

Flask's development server listens on 127.0.0.1 only: the deploy fails with “listening on localhost”. Use gunicorn.

requirements.txt
flask
gunicorn
Start command
gunicorn app:app --bind 0.0.0.0:$PORT

Django

Start command
python manage.py migrate --noinput && gunicorn myproject.wsgi --bind 0.0.0.0:$PORT
settings.py
import os
ALLOWED_HOSTS = [".dockhosting.cloud", "your-domain.com"]
CSRF_TRUSTED_ORIGINS = ["https://*.dockhosting.cloud", "https://your-domain.com"]
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")

For the database, read DATABASE_URL, for example with dj-database-url:

settings.py
import dj_database_url
DATABASES = {"default": dj_database_url.config(conn_max_age=600)}

FastAPI

Start command
uvicorn main:app --host 0.0.0.0 --port $PORT

Streamlit

We find your Streamlit script and start it for you. To set it yourself:

Start command
streamlit run app.py --server.address 0.0.0.0 --server.port $PORT

Python version

Pin it with a .python-version or runtime.txt file (for example 3.12).

On this page