Workers - Python Workers handlers now live in an entrypoint class
10mo ago
Source
CloudflareWorkers - Python Workers handlers now live in an entrypoint classcloudflare.comWe are changing how Python Workers are structured by default. Previously, handlers were defined at the top-level of a module as on_fetch , on_scheduled , etc. methods, but now they live in an entrypoint class. Here's an example of how to now define a Worker with a fetch handler: from workers import Response , WorkerEntrypoint class Default ( WorkerEntrypoint ): async def fetch ( self , request ): return Response ( "Hello World!" ) To keep using the old-style handlers, you can specify the disable_python_no_global_handlers compatibility flag in your wrangler file: wrangler.jsonc { " compatibility_flags " : [ "disable_python_no_global_handlers" ] } wrangler.toml compatibility_flags = [ "disable_python_no_global_handlers" ] Consult the Python Workers documentation for more details.
You might also wanna read
Cloudflare expands AI bot management tools with granular traffic controls for all customers
Cloudflare is celebrating the second "Content Independence Day" by expanding AI traffic management options for all website owners. Building
Workers - Simpler runtime types with @cloudflare/workers-types v5
Cloudflare·1d ago
AI Search - Manage AI Search sync jobs with Wrangler CLI
Cloudflare·2d ago
Workers - Work across multiple accounts with Wrangler auth profiles
Cloudflare·2d ago
Cache - Cache multiple versions of a URL with Vary
Cloudflare·2d ago
Cloudflare One - Hostname routing for Cloudflare Mesh
Cloudflare·2d ago

Comments
Sign in to join the conversation.
No comments yet. Be the first.