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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: astral-sh/setup-uv@v4

- name: Set up Python
run: uv python install
run: uv python install 3.13

- name: Install dependencies
run: |
Expand Down
4 changes: 0 additions & 4 deletions 03-fastapi/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# FastAPI + Jinja2 Example

Warning: Python support in Workers is experimental and things will break. This
example is meant for reference only right now; you should be prepared to update
your code between now and official release time as APIs may change.

## How to Run

First ensure that `uv` is installed:
Expand Down
15 changes: 7 additions & 8 deletions 03-fastapi/src/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
environment = jinja2.Environment()
template = environment.from_string("Hello, {{ name }}!")


class Default(WorkerEntrypoint):
async def fetch(self, request):
import asgi

return await asgi.fetch(app, request.js_object, self.env)


app = FastAPI()


Expand All @@ -33,3 +25,10 @@ async def env(req: Request):
env = req.scope["env"]
message = f"Here is an example of getting an environment variable: {env.MESSAGE}"
return {"message": message}


class Default(WorkerEntrypoint):
async def fetch(self, request):
import asgi

return await asgi.fetch(app, request.js_object, self.env)
Loading
Loading