Home ci 38. functions / runtimes: Using the Python Runtime with Serverless Functions

38. functions / runtimes: Using the Python Runtime with Serverless Functions

Last updated on Aug 05, 2025

Using the Python Runtime with Serverless Functions

The Python runtime is available in Beta on all plans, enabling you to write Python code for Epycbyte Serverless Functions. This includes using frameworks like Django and Flask, with support for specific Python versions.

Quickstart Concepts

  • Table of Contents
    • Next.js
    • Python Version
    • Streaming
    • Dependencies
    • Advanced Usage
    • Reading Relative Files
    • Web Server Gateway Interface (WSGI)
    • Asynchronous Server Gateway Interface (ASGI)

Next.js

Epycbyte Functions support Next.js projects, allowing you to structure your application in the /app directory.

Python Version

  • Default: The latest available Python version is 3.12.
  • Legacy Support: 3.9 is available but requires a legacy build image.
  • Specification: You can specify the Python version using python_version in your Pipfile.

Streaming

Epycbyte Functions support streaming responses, enabling partial UI rendering as content loads.

Dependencies

  • Installation: Define dependencies in requirements.txt or Pipfile.
  • Example: Add Flask as a dependency with Flask == 3.0.3.

Advanced Usage

Web Server Gateway Interface (WSGI)

  • Use WSGI with frameworks like Flask or Django.
  • Example: Deploy a Flask application by defining a handler in your Python file.

Asynchronous Server Gateway Interface (ASGI)

  • Use ASGI with frameworks like Sanic.
  • Example: Define an app variable in your Python file and use Sanic for routing.

Reading Relative Files

Access files using relative paths. For example:

with open("path/to/file.txt", "r") as f:
    content = f.read()

Web Server Gateway Interface (WSGI)

The WSGI interface allows web servers to call Python applications. Use it with frameworks like Flask or Django.

Asynchronous Server Gateway Interface (ASGI)

The ASGI interface supports asynchronous applications. Define an app variable and use frameworks like Sanic.

from sanic import Sanic
from sanic.response import json

app = Sanic()

@app.route("/")
async def index(request):
    return json({"hello": "world"})

Conclusion

Epycbyte Functions provide a flexible environment for Python applications, supporting both synchronous and asynchronous workflows. Choose the right framework and structure your application to leverage these features effectively.