Python app
With a Python hosting plan your Python app (Flask, Django or another WSGI app) runs on our server with gunicorn, with its own database and Redis. You manage it from the dashboard: Hosting → website name → Application.
Before you start
- The app folder needs a requirements.txt file with the dependencies, including gunicorn.
- The app runs with gunicorn: the start command names the WSGI module and object, for example
gunicorn app:app(fileapp.py, objectapp). - We set the port and the number of processes: do not write
--bindor--workersin the start command.
When the website is created you find a starter “Site under construction” app (app.py and requirements.txt): replace it with yours.
Upload the app
Two ways:
- FTP: upload the files to the website's www folder (FTP). Do not upload the
.venvfolder or other virtual environments: we create the environment. - Git: connect the repository (Git deploy). On every update we install the dependencies and restart the app by ourselves. A www folder with only the starter app inside counts as empty: you can connect the repository without emptying it.
Install and start
After uploading the app click Install and start. In order:
- we create the
.venvenvironment in the www folder; - we install the dependencies with
pip install -r requirements.txt; - we check that gunicorn is there and start the app with the start command.
It can take a few minutes: the page refreshes by itself until it finishes. Next to the title you see the app status: Running, Starting or Stopped. If the installation fails, open Show the installation output to read the pip error.
Repeat Install and start whenever you change requirements.txt (with Git we do it for you).
Version and start command
In Version and start:
- Python version: 3.11, 3.12 or 3.13. When you change it the app reinstalls itself with the new version.
- Start command:
gunicorn module:object. Examples:gunicorn app:appfor Flask,gunicorn project.wsgifor Django (with your project's name instead ofproject). Letters, digits, spaces and the characters. _ / : = @ -are allowed.
Environment variables
In Environment variables add API keys and settings: we save them in the .env file of the www folder, readable only by the website. The app reads it with the python-dotenv package:
from dotenv import load_dotenv
load_dotenv()
Remember to add python-dotenv to requirements.txt. Variables apply from the next Restart. A value cannot contain both single quotes and double quotes (or backslashes).
Database and Redis
Every app has its own MySQL (MariaDB) database and Redis, already connected: the app gets them as environment variables (os.environ).
DB_HOST,DB_NAME,DB_USER,DB_PASSWORDREDIS_HOST,REDIS_PORT,REDIS_PASSWORD
You also find the database credentials in the dashboard, in Databases.
Restart
Restart starts the app again, for example after changing the environment variables.
If the app does not start
- Check the start command: the module and object must exist (
gunicorn app:appneeds anapp.pyfile containingapp). - Check that
gunicornis inrequirements.txt. - Read the output of the last installation and the app log, the website's
logs/python.logfile, which you find via FTP or in the dashboard under Files → File Manager.