Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/content/docs/workers/languages/python/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Or you can clone the examples repository to explore more options:

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

## Next Up
Expand Down
19 changes: 6 additions & 13 deletions src/content/docs/workers/languages/python/packages/fastapi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ app = FastAPI()
def read_root():
return {"Hello": "World"}

import asgi
from workers import WorkerEntrypoint

class Default(WorkerEntrypoint):
async def fetch(self, request):
return await asgi.fetch(app, request, self.env)
from workers import asgi
Default = asgi.entrypoint(app)
```

3. Create a `wrangler.jsonc` file to configure your Worker:
Expand Down Expand Up @@ -127,16 +123,13 @@ dev = [
Then write your worker:

```python title="src/worker.py"
from workers import WorkerEntrypoint
from fastapi import FastAPI, Request
from fastapi.responses import Response
import asgi
from workers import asgi

class Default(WorkerEntrypoint):
async def fetch(self, request):
return await asgi.fetch(app, request, self.env)

app = FastAPI()
Default = asgi.entrypoint(app)

@app.get("/api/hello")
async def api_hello():
Expand Down Expand Up @@ -166,6 +159,6 @@ Clone the `cloudflare/python-workers-examples` repository and run the FastAPI ex

```bash
git clone https://github.com/cloudflare/python-workers-examples
cd python-workers-examples/03-fastapi
cd python-workers-examples/fastapi
uv run pywrangler dev
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Clone the `cloudflare/python-workers-examples` repository and run the LangChain

```bash
git clone https://github.com/cloudflare/python-workers-examples
cd 05-langchain
cd python-workers-examples/langchain
uv run pywrangler dev
```

Expand Down