Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/content/docs/workers/languages/python/examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ Cloudflare has a wide range of Python examples in the [Workers Example gallery](

In addition to those examples, consider the following ones that illustrate Python-specific behavior.

## Modules in your Worker

Let's say your Worker has the following structure:

```
├── src
│   ├── module.py
│   └── main.py
├── uv.lock
├── pyproject.toml
└── wrangler.toml
```

In order to import `module.py` in `main.py`, you would use the following import statement:

```python
import module
```

In this case, the main module is set to `src/main.py` in the wrangler.toml file like so:

```toml
main = "src/main.py"
```

This means that the `src` directory does not need to be specified in the import statement.

## Parse an incoming request URL

```python
Expand Down