On this page

Python

Guara Cloud fully supports Python applications, including frameworks like Django, Flask, FastAPI, and any other Python-based project.

Supported versions

The following Python versions are auto-detected:

  • Python 3.10
  • Python 3.11
  • Python 3.12

The version is auto-detected from your project configuration files (e.g., pyproject.toml, Pipfile, or .python-version). If no version is specified, the latest stable version is used.

Deploy with Dockerfile

For full control over your build, provide a Dockerfile in the root of your repository.

FROM python:3.12-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 3000

CMD ["gunicorn", "--bind", "0.0.0.0:3000", "app:app"]

Deploy with Buildpack

If your repository does not contain a Dockerfile, Guara Cloud automatically detects your Python project by the presence of a requirements.txt, pyproject.toml, Pipfile, or similar dependency file.

The auto-detection will:

  1. Detect the Python version from your project configuration
  2. Detect your package manager (pip, poetry, pdm, uv, or pipenv) and install dependencies accordingly
  3. Detect your framework (Django, Flask, or FastAPI)
  4. Auto-configure the production server — gunicorn for Django/Flask, uvicorn for FastAPI
  5. Start your application automatically

No Procfile is needed — the framework and server are detected and configured for you.

Port configuration

Your application must listen on the port configured in your service settings. The default is 3000, but you can change it at any time to match your application.

import os

port = int(os.environ.get('PORT', 3000))

Example project structure

my-python-app/
  requirements.txt
  runtime.txt          # optional — specify Python version if needed
  app.py
  src/
    routes.py
    models.py
  Dockerfile          # optional — omit to use Buildpack

Environment variables

These environment variables are commonly used with Python deployments:

VariableRecommended valueDescription
PYTHONUNBUFFERED1Ensures logs are output in real time without buffering
PORTSet by platformThe port your application must listen on
PYTHONDONTWRITEBYTECODE1Prevents Python from writing .pyc files

Common pitfalls