Deploy a Python App (Flask / FastAPI)
This guide covers deploying Python web applications that are not Django — such as Flask, FastAPI, Starlette, or any WSGI/ASGI app — to your own server using Appliku.
If you are deploying a Django application, see the dedicated Deploy Django guide instead.
Prerequisites
Before you begin, make sure you have:
- A Python web application with a
requirements.txtin the root of the repository - Your code pushed to a GitHub or GitLab repository
- An Appliku account with at least one server set up
Step 1: Create an Application from GitHub
Go to the Applications page in your Appliku dashboard and click + Add Application.
Select GitHub (or GitLab) as the source, then fill in the form:
- Application name — a descriptive name for your app
- Repository — select your Python repository
- Branch — the branch to deploy from (e.g.,
mainormaster) - Server — the server to deploy to
Click Create Application.
Step 2: Select the Python Build Image
On the application overview page, go to Settings and open the Build Settings tab.
Change the Base Docker Image to a Python option (e.g., Python 3.12). Pick the version that matches your project.
Step 3: Set the Build Command
In the same Build Settings tab, set the Build Command to install your dependencies:
pip install -r requirements.txt
If you use a pyproject.toml with pip, you can use:
pip install .
Click Save Changes.
Step 4: Set the Container Port
Appliku routes HTTP traffic to your web process container. The default port is 8000, which works well for most Python deployments.
If your application listens on a different port, go to the Build Settings tab and update the Container Port accordingly.
Step 5: Add a Web Process
Go to the Processes tab and add a process:
- Name:
web - Command: the command that starts your application in production
The web process is special — it is the process that receives HTTP traffic through Nginx.
Flask
For a Flask application, use Gunicorn as the production server:
gunicorn app:app --bind 0.0.0.0:8000
Where app:app means "import the app object from the app module." Adjust this to match your project structure (e.g., mypackage.main:app).
FastAPI
For a FastAPI application, use Uvicorn:
uvicorn main:app --host 0.0.0.0 --port 8000
Where main:app means "import the app object from the main module." Adjust to match your project.
For better performance in production, you can run Uvicorn workers under Gunicorn:
gunicorn main:app --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
Other WSGI/ASGI Apps
For any WSGI app, Gunicorn works as a production server. For ASGI apps, use Uvicorn or Hypercorn.
Click Save and Deploy.
Step 6: Deploy
Appliku will build your Docker image, install dependencies, and start the web process. You can monitor the build progress on the application overview page.
Once deployed, click View Application to open your app in the browser.
Tips
Always Use a Production Server
Never run Flask's built-in development server (flask run) or Uvicorn with --reload in production. Always use Gunicorn or Uvicorn without the reload flag.
Bind to 0.0.0.0
Make sure your server binds to 0.0.0.0, not 127.0.0.1. Binding to localhost inside a Docker container makes the app unreachable from outside the container.
requirements.txt vs pyproject.toml
Appliku's Python build images look for requirements.txt by default. If you manage dependencies with pyproject.toml, Poetry, or PDM, make sure your build command installs dependencies correctly. You can always generate a requirements.txt from your tool of choice:
# Poetry
poetry export -f requirements.txt -o requirements.txt
# pip-compile (pip-tools)
pip-compile pyproject.toml -o requirements.txt
Adding a Release Process
If your app needs to run database migrations or other setup tasks after each deployment, add a release process:
- Name:
release - Command: your migration or setup command, for example:
flask db upgrade
or
alembic upgrade head
The release process runs once after each successful build, before the new version starts serving traffic.
Adding a Database
If your application needs a database, scroll down on the application overview page and click Add Database to provision PostgreSQL or Redis on the same server. The connection URL will be automatically added to your environment variables.
Environment Variables
Store secrets and configuration (database URLs, API keys, secret keys) in Environment Variables rather than hardcoding them in your source code.
Related Guides
- Deploy Django — if you are deploying a Django application
- Processes — learn more about process types and configuration