cloudflare/python-workers-examples
Acerca de
This is a collection of examples for writing Cloudflare Workers in Python. Use these examples to learn how Python Workers work.
Herramientas de desarrolloCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
OriginalPython Workers Examples
This is a collection of examples for writing Cloudflare Workers in Python. Use these examples to learn how Python Workers work.
Get started
git clone https://github.com/cloudflare/python-workers-examplescd hellouvx --from workers-py pywrangler dev- Press the
bkey to open a browser tab, and make a request to your Worker
You can run uvx --from workers-py pywrangler dev in any example project directory to run a local development server using Pywrangler, the CLI for Cloudflare Python Workers. This local development server is powered by workerd, the open-source Workers runtime.
Need to deploy your Worker to Cloudflare? Python Workers are in open beta and have a few limitations.
Examples
hello/— the most basic Python Workerbinding/— shows how bindings work in Python Workers. Put a key into Workers KV, and then read it.fastapi/— demonstrates how to use the FastAPI package with Python Workersquery-d1/- shows how to query D1 with Python Workersmcp-server/— an MCP server backed by D1.langchain/— demonstrates how to use the LangChain package with Python Workers. Currently broken.assets/— An example with an assets binding.durable-objects/— An example with storing state in a Durable Object.hyperdrive-batched-counter/— batches high-frequency counters with Durable Objects and PostgreSQL through Hyperdrive.cron/— shows a simple cron job.workers-ai/makes a call Workers AI to run inference on Cloudflare's Global Network.vectorize-rag/— a RAG example using remote Workers AI and Vectorize bindings.workflows/— shows a durable Workflows example.opengraph/— shows how to use HTMLRewriter to generate OpenGraph images with Python Workers.image-gen/— shows how to use Pillow to generate images with Python Workers.js-api-pygments/— shows how to use Pygments to highlight code with Python Workers.websocket-stream-consumer/— shows how to use WebSocket to consume a stream of data with Python Workers.chatroom/- A real-time chatroom using WebSocket.sync-http-clients/— demonstrates outbound HTTP with synchronous Python clients (requests,urllib3, andhttpx.Client).url-shortener/— a URL shortener backed by Workers KV.dynamic-py-py/— shows how to load and run a Python Worker dynamically at runtime using a Worker Loader binding.image-redraw/— an example that combines FastAPI, R2, Queues, Workflows and Workers AI to redraw uploaded images.django/— runs a naive Django WSGI application directly on Python Workers.django-todo-d1/— uses Django with D1 for a basic TODO application.django-markdown-r2/— a server-rendered Django blog using Durable Object SQLite and R2 for media storage.fastapi-todo/— implements the Todo-Backend spec with FastAPI (ASGI) and D1.flask-todo/— implements the same Todo-Backend API with Flask (WSGI) and D1.
Open Beta and Limits
- 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.
License
The Apache 2.0 license.
Explorar proyectos relacionados
Cargando…