diff --git a/01-hello/README.md b/01-hello/README.md index 81fdafc..adf6de0 100644 --- a/01-hello/README.md +++ b/01-hello/README.md @@ -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. diff --git a/02-binding/README.md b/02-binding/README.md index a4d0889..d03042a 100644 --- a/02-binding/README.md +++ b/02-binding/README.md @@ -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. diff --git a/03-fastapi/README.md b/03-fastapi/README.md index c510610..326ca16 100644 --- a/03-fastapi/README.md +++ b/03-fastapi/README.md @@ -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: diff --git a/04-query-d1/README.md b/04-query-d1/README.md index 5f05313..218f7d6 100644 --- a/04-query-d1/README.md +++ b/04-query-d1/README.md @@ -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. diff --git a/04-query-d1/package.json b/04-query-d1/package.json index 50c650e..62a03fc 100644 --- a/04-query-d1/package.json +++ b/04-query-d1/package.json @@ -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" }, diff --git a/06-assets/README.md b/06-assets/README.md index 6d1a1ee..ecc08fb 100644 --- a/06-assets/README.md +++ b/06-assets/README.md @@ -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. diff --git a/07-durable-objects/README.md b/07-durable-objects/README.md index 9534f7f..ed71726 100644 --- a/07-durable-objects/README.md +++ b/07-durable-objects/README.md @@ -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: diff --git a/08-cron/README.md b/08-cron/README.md index ee54dcb..2eef0d6 100644 --- a/08-cron/README.md +++ b/08-cron/README.md @@ -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: diff --git a/09-workers-ai/README.md b/09-workers-ai/README.md index 684ac87..e1ad20d 100644 --- a/09-workers-ai/README.md +++ b/09-workers-ai/README.md @@ -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: diff --git a/10-workflows/README.md b/10-workflows/README.md index c17a1f7..67defac 100644 --- a/10-workflows/README.md +++ b/10-workflows/README.md @@ -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: diff --git a/11-opengraph/README.md b/11-opengraph/README.md index 4d64bb4..3973922 100644 --- a/11-opengraph/README.md +++ b/11-opengraph/README.md @@ -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 diff --git a/12-image-gen/README.md b/12-image-gen/README.md index fa555fa..a351dbc 100644 --- a/12-image-gen/README.md +++ b/12-image-gen/README.md @@ -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 diff --git a/14-websocket-stream-consumer/README.md b/14-websocket-stream-consumer/README.md index 26fd8ab..774e140 100644 --- a/14-websocket-stream-consumer/README.md +++ b/14-websocket-stream-consumer/README.md @@ -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 diff --git a/14-websocket-stream-consumer/wrangler.jsonc b/14-websocket-stream-consumer/wrangler.jsonc index f9c2bda..a63fce3 100644 --- a/14-websocket-stream-consumer/wrangler.jsonc +++ b/14-websocket-stream-consumer/wrangler.jsonc @@ -13,8 +13,7 @@ "bindings": [ { "name": "BLUESKY_FIREHOSE", - "class_name": "BlueskyFirehoseConsumer", - "script_name": "python-websocket-stream-consumer" + "class_name": "BlueskyFirehoseConsumer" } ] }, diff --git a/15-chatroom/README.md b/15-chatroom/README.md index 4d21ea9..6292a15 100644 --- a/15-chatroom/README.md +++ b/15-chatroom/README.md @@ -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: diff --git a/15-chatroom/wrangler.jsonc b/15-chatroom/wrangler.jsonc index c0dac62..9b1f806 100644 --- a/15-chatroom/wrangler.jsonc +++ b/15-chatroom/wrangler.jsonc @@ -13,8 +13,7 @@ "bindings": [ { "name": "CHATROOM", - "class_name": "Chatroom", - "script_name": "python-chatroom" + "class_name": "Chatroom" } ] }, diff --git a/16-sync-http-clients/README.md b/16-sync-http-clients/README.md index fe6a634..f3572c0 100644 --- a/16-sync-http-clients/README.md +++ b/16-sync-http-clients/README.md @@ -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/) diff --git a/17-dynamic-py-py/README.md b/17-dynamic-py-py/README.md index df26429..7ca9db2 100644 --- a/17-dynamic-py-py/README.md +++ b/17-dynamic-py-py/README.md @@ -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.