Python apps are available on Pro and above. As with Node.js, you connect a git repository and we build and run it for you.
Setting it up
- Go to Apps and choose New app.
- Select Python.
- Connect your git repository and pick the branch.
- Point us at your dependency file, normally
requirements.txt. - Set your start command. Typical examples:
- Django: a WSGI server command such as
gunicorn myproject.wsgi - Flask:
gunicorn app:app - FastAPI:
uvicorn main:app --host 0.0.0.0
Read the port from the environment rather than hard-coding one.
- Add your environment variables, including your secret key and database connection details.
- Choose the domain or subdomain.
- Deploy.
We create the environment, install your dependencies, start the app and serve it over HTTPS.
Django specifics
- Add your domain to
ALLOWED_HOSTS. - Run
collectstaticas part of your build so your static files are ready to serve. - Run your migrations. You can do this as part of the deploy, or manually from the panel.
- Set
DEBUGto false in production. It is a security problem otherwise.
Databases
Create a PostgreSQL or MySQL database in the Databases section and pass the connection details in as environment variables. Never commit them to the repository.
Background workers and scheduled tasks
If your application needs a worker process or a scheduled job, set it up in the panel alongside the app. If you are not sure how your particular stack should be arranged, email [email protected] and describe what you are running.
Resources
Your app runs within your plan's guaranteed memory and CPU. If a process is killed for using too much memory, either reduce your worker count or move up a plan. Premium gives 3 GB and 4 cores, Platinum 5 GB and 6 cores.
Logs
Build and run-time logs are shown in the panel under the app. Start there whenever a deploy or a request fails.
The assistant in your control panel can see your actual account and answer about your sites, your plan and your usage. For anything else, email [email protected] and a person will answer.