Cloudflare Workers Python SDK

0.0.8 · active · verified Tue Mar 17

Python SDK for building Cloudflare Workers. Allows writing serverless functions in Python that run on the Cloudflare edge network using Pyodide (CPython compiled to WebAssembly). This is distinct from the 'cloudflare' package which is the API client for managing Cloudflare resources.

Warnings

Install

Imports

Quickstart

Minimal Cloudflare Worker in Python. The on_fetch handler is the entry point for HTTP requests. Deploy with wrangler after configuring wrangler.toml with compatibility_flags = ["python_workers"].

from cloudflare.workers import Response

async def on_fetch(request, env):
    return Response('Hello from Python Workers!')

view raw JSON →