Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 01-hello/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Hello World Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/01-hello)

Warning: Python support in Workers is experimental and things will break. This
example is meant for reference only right now; you should be prepared to update
your code between now and official release time as APIs may change.
Expand Down
2 changes: 2 additions & 0 deletions 02-binding/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Environment Binding Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/02-binding)

Warning: Python support in Workers is experimental and things will break. This
example is meant for reference only right now; you should be prepared to update
your code between now and official release time as APIs may change.
Expand Down
2 changes: 2 additions & 0 deletions 03-fastapi/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# FastAPI + Jinja2 Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/03-fastapi)

## How to Run

First ensure that `uv` is installed:
Expand Down
2 changes: 2 additions & 0 deletions 04-query-d1/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# D1 Database Query Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/04-query-d1)

Warning: Python support in Workers is experimental and things will break. This
example is meant for reference only right now; you should be prepared to update
your code between now and official release time as APIs may change.
Expand Down
3 changes: 2 additions & 1 deletion 04-query-d1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"deploy": "uv run pywrangler deploy",
"db:init": "uv run pywrangler d1 execute DB --remote --file db_init.sql",
"deploy": "npm run db:init && uv run pywrangler deploy",
"dev": "uv run pywrangler dev",
"start": "uv run pywrangler dev"
},
Expand Down
2 changes: 2 additions & 0 deletions 06-assets/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Assets Handling Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/06-assets)

Warning: Python support in Workers is experimental and things will break. This
example is meant for reference only right now; you should be prepared to update
your code between now and official release time as APIs may change.
Expand Down
2 changes: 2 additions & 0 deletions 07-durable-objects/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Durable Objects Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/07-durable-objects)

## How to Run

First ensure that `uv` is installed:
Expand Down
2 changes: 2 additions & 0 deletions 08-cron/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Cron Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/08-cron)

## How to Run

First ensure that `uv` is installed:
Expand Down
2 changes: 2 additions & 0 deletions 09-workers-ai/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Workers AI Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/09-workers-ai)

## How to Run

First ensure that `uv` is installed:
Expand Down
2 changes: 2 additions & 0 deletions 10-workflows/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Workflows Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/10-workflows)

## How to Run

First ensure that `uv` is installed:
Expand Down
2 changes: 2 additions & 0 deletions 11-opengraph/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# OpenGraph Meta Tag Injection Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/11-opengraph)

This example demonstrates how to build a Python Worker that dynamically injects OpenGraph meta tags into web pages based on the request path. This is perfect for controlling how your content appears when shared on social media platforms like Facebook, Twitter, LinkedIn, and Slack.

## What It Does
Expand Down
2 changes: 2 additions & 0 deletions 12-image-gen/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Image Generation with Pillow Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/12-image-gen)

This example demonstrates how to build a Python Worker that dynamically generates images using the Pillow (PIL) library.

## What It Does
Expand Down
2 changes: 2 additions & 0 deletions 14-websocket-stream-consumer/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# WebSocket Stream Consumer - Bluesky Firehose

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/14-websocket-stream-consumer)

This example demonstrates a long-running Durable Object that connects to the Bluesky firehose (via Jetstream) and filters for post events, with rate limiting to print at most 1 per second.

## How to Run
Expand Down
3 changes: 1 addition & 2 deletions 14-websocket-stream-consumer/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"bindings": [
{
"name": "BLUESKY_FIREHOSE",
"class_name": "BlueskyFirehoseConsumer",
"script_name": "python-websocket-stream-consumer"
"class_name": "BlueskyFirehoseConsumer"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions 15-chatroom/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# WebSocket chatroom

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/15-chatroom)

## How to Run

First ensure that `uv` is installed:
Expand Down
3 changes: 1 addition & 2 deletions 15-chatroom/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"bindings": [
{
"name": "CHATROOM",
"class_name": "Chatroom",
"script_name": "python-chatroom"
"class_name": "Chatroom"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions 16-sync-http-clients/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Sync HTTP Clients Example

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/16-sync-http-clients)

This example demonstrates outbound HTTP from a Python Worker using synchronous Python HTTP clients known to work in the current runtime:

- [`requests`](https://pypi.org/project/requests/)
Expand Down
2 changes: 2 additions & 0 deletions 17-dynamic-py-py/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 17-dynamic-py-py — Python Worker loads a Python Dynamic Worker

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/python-workers-examples/tree/main/17-dynamic-py-py)

This example shows how a Python Worker can use the [Worker Loader](https://developers.cloudflare.com/dynamic-workers/) binding to dynamically load and execute another Python Worker at runtime.

The parent Python Worker keeps the source of the dynamic Worker as a string (for demonstration purposes — in a real application you would load it from KV, R2, or any other storage). Each request is forwarded to the dynamically-loaded Worker, which runs in its own isolated sandbox.
Expand Down
Loading