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
- 1Create api/hello.py with a handler.
- 2Add requirements.txt if it imports packages.
- 3Deploy.
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.
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 engineThings 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.
| Limit | Free | Pro |
|---|---|---|
| Build minutes | 3,000/mo, 1 concurrent | 10,000/mo, 3 concurrent |
| Function memory / timeout | 1 GB / 300 s | 4 GB / 1800 s |
| Function invocations | 2 M/mo | 20 M/mo |
| Bandwidth | 150 GB/mo | 2 TB/mo |
Related guides
- Deploy a FastAPI appFastAPI (and Starlette) apps as ASGI functions on Python 3.12.
- Deploy a Flask appFlask (and Quart) apps served as WSGI/ASGI functions.
- Deploy a Node.js functions appAn api/ folder of functions that scale to zero, with no framework at all.
Ship your Python functions project tonight
Connect the repository and the build settings fill themselves in. Free plan, no card.