You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Python Worker can be as simple as three lines of code:
@@ -48,16 +50,25 @@ class Default(WorkerEntrypoint):
48
50
49
51
Similar to Workers written in [JavaScript](/workers/languages/javascript), [TypeScript](/workers/languages/typescript), or [Rust](/workers/languages/rust/), the main entry point for a Python worker is the [`fetch` handler](/workers/runtime-apis/handlers/fetch). In a Python Worker, this handler is placed in a `Default` class that extends the `WorkerEntrypoint` class (which you can import from the `workers` SDK module).
50
52
51
-
To run a Python Worker locally, you use [Wrangler](/workers/wrangler/), the CLI for Cloudflare Workers:
53
+
To run a Python Worker locally, you use pywrangler, the CLI for Python Workers.
54
+
To set it up, first you need to set up your development environment:
55
+
```
56
+
uv init
57
+
uv tool install workers-py
58
+
uv run pywrangler init
59
+
```
60
+
This will create a `pyproject.toml` file with `workers-py` as a development
61
+
dependency. `pywrangler init` will create a wrangler config file. You can then
62
+
run `pywrangler` with:
52
63
53
64
```bash
54
-
npx wrangler@latest dev
65
+
uv run pywrangler dev
55
66
```
56
67
57
-
To deploy a Python Worker to Cloudflare, run [`wrangler deploy`](/workers/wrangler/commands/#deploy):
68
+
To deploy a Python Worker to Cloudflare, run `pywrangler deploy`:
0 commit comments