Skip to content

Python

Deploy a Python functions app on Enzonic

For small endpoints, skip the framework: a file in api/ with a handler(request) function becomes an endpoint. It can return a dict (sent as JSON), a string, bytes, or a (body, status, headers) tuple. ASGI and WSGI apps in api/ work too.

At a glance

What Enzonic Deploy does with a Python functions project when you connect it. You can override any of it in the project settings.

Language
Python
Detected from
api/*.py files, with no Django, FastAPI or Flask app detected first
Build command
pip install -r requirements.txt, if present
Output
Functions
Runs as
Functions

How it runs

  • Functions

    Always.

Deploy Python functions step by step

  1. 1Create api/hello.py with a handler.
  2. 2Add requirements.txt if it imports packages.
  3. 3Deploy.
api/hello.py
def handler(request):
    name = request.query.get('name', 'world')
    return {'hello': name}

Connect a database to Python functions

Create a database on Enzonic Databases (or from the project's settings) and its connection string is added to the project's environment variables. This example uses Valkey.

api/cache.py
import os, redis

r = redis.from_url(os.environ['REDIS_URL'])

def handler(request):
    return {'hits': r.incr('hits')}

Postgres projects get two variables: DATABASE_URL through the connection pooler for the app, and DATABASE_URL_UNPOOLED for migrations.

Valkey on Enzonic DatabasesEvery database engine

Things to know

  • Module-level code runs once per warm instance: open connections there, not inside the handler.

Plan limits that matter here

From the live plan data. Every plan includes previews for each branch, instant rollback, environment variables and logs.

Plan limits that matter for Python functions
LimitFreePro
Build minutes3,000/mo, 1 concurrent10,000/mo, 3 concurrent
Function memory / timeout1 GB / 300 s4 GB / 1800 s
Function invocations2 M/mo20 M/mo
Bandwidth150 GB/mo2 TB/mo

Compare every plan

Related guides

Ship your Python functions project tonight

Connect the repository and the build settings fill themselves in. Free plan, no card.

Start free