Python Workers (2)

Last updated Sep 17, 2026 Cloudflare Workers provides a first-class Python experience, including support for:

Introduction

A Python Worker can be as simple as four lines of code:

from workers import WorkerEntrypoint, Response

class Default(WorkerEntrypoint):
    async def fetch(self, request):
        return Response("Hello World!")

Similar to other Workers, the main entry point for a Python worker is the fetch handler which handles incoming requests sent to the Worker.

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).

Note

You must add the python_workers compatibility flag to your Worker.

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.

The pywrangler CLI tool

To run a Python Worker locally, install packages, and deploy it to Cloudflare, you use pywrangler ↗︎, the CLI for Python Workers.

To set it up, first, ensure uv ↗︎ and Node ↗︎ are installed.

Then set up your development environment:

uvx --from workers-py pywrangler init

This will create a pyproject.toml file with workers-py as a development dependency. pywrangler init will create a wrangler config file. You can then run pywrangler with:

uv run pywrangler dev

To deploy a Python Worker to Cloudflare, run pywrangler deploy:

uv run pywrangler deploy

Python Worker Templates

When you initialize a new Python Worker project and select from one of many templates:

uv run pywrangler init

Or you can clone the examples repository to explore more options:

git clone https://github.com/cloudflare/python-workers-examples
cd python-workers-examples/hello

Next Up

Was this helpful?

YesNo

On this page

Python Workers (2) - 图1Docs

{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers/languages/python/#page","headline":"Python Workers","description":"Write Workers in 100% Python","url":"https://developers.cloudflare.com/workers/languages/python/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/languages/python/og.png?v=900a36ef7801c922","dateModified":"2026-09-17","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Learn the basics of Python Workers title: The Basics image: https://developers.cloudflare.com/workers/languages/python/basics/og.png?v=34d0ab0db9ff32c9


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.