Prompt Buddy logoPrompt Buddy

cloudflare · Cloudflare Workers Docs

Workers The Basics

Teaches how to implement a basic Python Worker by defining a fetch handler within a Default class, accessing the Request interface via FFI, utilizing the env attribute for environment variables, and structuring code a...

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Workers The Basics

Teaches how to implement a basic Python Worker by defining a fetch handler within a Default class, accessing the Request interface via FFI, utilizing the env attribute for environment variables, and structuring code a...

When To Use

Use when you need to implement a basic Python-based Cloudflare Worker, handle incoming HTTP requests, access environment variables, or organize worker code into multiple files.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/workers-python-basics-the-workflow-guide.mdA guide covering the fetch handler, request interface, env attribute, and modules for Python Workers.Questions about a guide covering the fetch handler, request interface, env attribute, and modules for Python Workers.
examples/workers-python-basics-the-cloudflare-workers-python-basics-hello-world.textA basic Python implementation of a Cloudflare Worker using the WorkerEntrypoint class to return a Hello World response.Exact payloads, commands, or snippets shown in A basic Python implementation of a Cloudflare Worker using the WorkerEntrypoint class to return a Hello World response.
examples/workers-python-basics-the-cloudflare-workers-python-basics-entrypoint.textA Python code example demonstrating how to implement a WorkerEntrypoint and handle a fetch request in a Cloudflare Worker.Exact payloads, commands, or snippets shown in A Python code example demonstrating how to implement a WorkerEntrypoint and handle a fetch request in a Cloudflare Wo...
examples/workers-python-basics-the-cloudflare-workers-python-basics-curl-request.textA curl command demonstrating how to send a POST request with a JSON payload to a local Cloudflare Workers Python environment.Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a POST request with a JSON payload to a local Cloudflare Workers Python envi...
examples/workers-python-basics-the-cloudflare-workers-python-hello-world.textA basic Python script for a Cloudflare Worker that returns a 'Hello, Python!' response.Exact payloads, commands, or snippets shown in A basic Python script for a Cloudflare Worker that returns a 'Hello, Python!' response.
examples/workers-python-basics-the-cloudflare-workers-python-basics-wrangler-toml.textA wrangler.toml configuration file for a Python-based Cloudflare Worker including compatibility flags and environment variables.Exact payloads, commands, or snippets shown in A wrangler.toml configuration file for a Python-based Cloudflare Worker including compatibility flags and environment...
examples/workers-python-basics-the-cloudflare-workers-python-wrangler-toml-config.textA wrangler.toml configuration file for a Python-based Cloudflare Worker including schema references and compatibility flags.Exact payloads, commands, or snippets shown in A wrangler.toml configuration file for a Python-based Cloudflare Worker including schema references and compatibility...
examples/workers-python-basics-the-cloudflare-workers-python-basics-entrypoint-2.textA Python code example demonstrating how to implement a basic WorkerEntrypoint class with a fetch method.Exact payloads, commands, or snippets shown in A Python code example demonstrating how to implement a basic WorkerEntrypoint class with a fetch method.
examples/workers-python-basics-the-cloudflare-workers-python-hello-world-2.textA basic Python function implementation for a Cloudflare Worker that returns a greeting string.Exact payloads, commands, or snippets shown in A basic Python function implementation for a Cloudflare Worker that returns a greeting string.
examples/workers-python-basics-the-cloudflare-workers-python-basics-entrypoint-3.textA Python implementation of a Cloudflare Worker using the WorkerEntrypoint class to handle fetch requests.Exact payloads, commands, or snippets shown in A Python implementation of a Cloudflare Worker using the WorkerEntrypoint class to handle fetch requests.
examples/workers-python-basics-the-cloudflare-workers-python-basics-dependency-gr.textA text snippet showing the dependency-groups configuration for a Cloudflare Workers Python project including workers-py and workers-runtime-sdk.Exact payloads, commands, or snippets shown in A text snippet showing the dependency-groups configuration for a Cloudflare Workers Python project including workers-...
examples/workers-python-basics-the-cloudflare-workers-python-basics-uv-tool-upgra.textA command to upgrade the workers-py tool using the uv package manager.Exact payloads, commands, or snippets shown in A command to upgrade the workers-py tool using the uv package manager.
examples/workers-python-basics-the-cloudflare-workers-python-uv-lock-upgrade-comm.textA text snippet demonstrating the command to upgrade the workers-py package using the uv package manager.Exact payloads, commands, or snippets shown in A text snippet demonstrating the command to upgrade the workers-py package using the uv package manager.

What This Skill Covers

  • As mentioned in the introduction to Python Workers, a Python Worker can be as simple as four lines of code:
  • Main sections: Fetch Handler, The Request Interface, The env Attribute, Modules, Types and Autocompletion.

Workflow

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. Do not add behavior or configuration that is not present in the attached source files.

Canonical source: https://developers.cloudflare.com/workers/languages/python/basics