This is a collection of examples for writing Cloudflare Workers in Python. Use these examples to learn how Python Workers work.
git clone https://github.com/cloudflare/python-workers-examplescd hellonpx wrangler@latest dev- Press the
bkey to open a browser tab, and make a request to your Worker npx wrangler@latest deployto deploy your Worker to Cloudflare
You can run npx wrangler@latest dev in any example project directory to run a local development server using Wrangler, the CLI for Cloudflare Workers. This local development server is powered by workerd, the open-source Workers runtime.
01-hello/— the most basic Python Worker02-binding/— shows how bindings work in Python Workers. Put a key into Workers KV, and then read it.03-fastapi/— demonstrates how to use the FastAPI package with Python Workers04-langchain/— demonstrates how to use the LangChain package with Python Workers
- Python Workers are in open beta. You can currently only use built-in packages in local development. Support for deploying Workers with a
requirements.txtfile is coming soon. - You must add the
python_workerscompatibility flag to your Worker, while Python Workers are in open beta.
We’d love your feedback. Join the #python-workers channel in the Cloudflare Developers Discord and let us know what you’d like to see next.
The Apache 2.0 license.