Add flask in Python workers documentation - #33074
Conversation
Review
👉 Fix in your agent 👈Fix the following review findings in PR #33074 (https://github.com/cloudflare/cloudflare-docs/pull/33074).
Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.
The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.
---
## Code Review
### Warnings (3)
#### CR-597a4b4f251e · Incorrect framework name
- **File:** `src/content/docs/workers/languages/python/packages/flask.mdx` line 109
- **Issue:** Line 109 refers to a 'FastAPI Worker' while this is the Flask documentation page. This appears to be a copy-paste error from the FastAPI guide.
- **Fix:** Change 'FastAPI Worker' to 'Flask Worker' so the sentence correctly describes the Worker being documented.
#### CR-ffccc57d94d7 · Incorrect example response
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 90
- **Issue:** The `src/main.py` example returns `{"Hello": "World"}`, but the Quick Start output block shows `{"message":"Hello from Flask"}`. The body is wrong and it references Flask instead of FastAPI.
- **Fix:** Update the output to match the example, e.g. `{"Hello":"World"}`, and remove the Flask reference.
#### CR-03e7d6ae8b9e · Unsafe header passthrough
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 167
- **Issue:** The catch-all route passes `resp.headers` directly to FastAPI's `Response`. The `resp` object comes from `env.ASSETS.fetch(...)`, which returns a Workers/web `Response` whose `.headers` object is not a Python `dict` and may not be accepted by Starlette's `Response` headers argument.
- **Fix:** Convert the headers to a Python dict, e.g. `headers = dict(resp.headers)`, and pass `headers=headers` to `Response`.
---
## Conventions
### Warnings (2)
#### CV-53e0d8fdc6ac · Description explains the work
- **File:** PR-level finding
- **Issue:** The description contains only a checked style-guide checklist item ("- [x] The change adheres to the documentation style guide.") with no explanation of what the PR does.
- **Fix:** Add a human-written sentence or two describing the new Flask documentation and the FastAPI packages page update.
#### CV-c8dc0fe9abdf · Scope accuracy
- **File:** PR-level finding
- **Issue:** The PR adds two new Flask pages (src/content/docs/workers/framework-guides/apis/flask.mdx and src/content/docs/workers/languages/python/packages/flask.mdx) and modifies the FastAPI packages page (+30/-10), but the description is silent about all of these changes.
- **Fix:** Mention the added Flask pages and the FastAPI page update in the PR description so it accounts for the core changes.
---
## Style Guide Review
### Warnings (1)
#### SG-916a932c8215 · Incorrect framework name in prose
- **File:** `src/content/docs/workers/languages/python/packages/flask.mdx` line 109
- **Issue:** Line 109 says "This ensures every request reaches your FastAPI Worker first" in a Flask guide.
- **Fix:** Change "FastAPI Worker" to "Flask Worker".
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (3)
ConventionsWarnings (2)
Style Guide ReviewWarnings (1)
CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
| def index(): | ||
| return {"message": "Hello from Flask"} | ||
|
|
||
| Default = wsgi.entrypoint(app) |
287574f to
aad1ee9
Compare
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://hoodmane-flask-docs.previews.developers.cloudflare.com (commit aad1ee9)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
| return Response( | ||
| body, | ||
| status=asset_response.status, | ||
| headers=asset_response.headers, |
| The Worker returns: | ||
|
|
||
| ```json output | ||
| {"message":"Hello from Flask"} |
There was a problem hiding this comment.
| {"message":"Hello from Flask"} | |
| {"Hello": "World"} |
| `run_sync` bridges both asynchronous asset operations into Flask's synchronous | ||
| handler. API routes take priority, and unmatched paths are served from | ||
| `./public/`. |
There was a problem hiding this comment.
I prefer not to expose pyodide FFIs in cloudflare docs if possible, maybe let's replace it with asyncio.run or asyncio.run_until_complete.
There was a problem hiding this comment.
I still think those are confusing because they are not normally reentrant.
| ## More examples | ||
|
|
||
| Run the Flask todo example from the `python-workers-examples` repository. |
There was a problem hiding this comment.
This example already have readme in the link, so how about just linking the page without commands? That can prevent this example being out of sync.
| ## Serve a frontend | ||
|
|
||
| You can serve a single-page application (SPA) or any static frontend alongside your FastAPI backend by using [Workers Static Assets](/workers/static-assets/). | ||
| You can serve any static frontend alongside your FastAPI backend by using [Workers Static Assets](/workers/static-assets/). |
| ## Prerequisites | ||
|
|
||
| You need [`uv`](https://docs.astral.sh/uv/) and [`node`](https://nodejs.org/) installed. |
There was a problem hiding this comment.
Nit: I'd drop this, folks will be able to work this out and it's not ideal to have it so far up the page IMO
| @@ -0,0 +1,8 @@ | |||
| --- | |||
| pcx_content_type: navigation | |||
There was a problem hiding this comment.
Should this be added to the index? https://developers.cloudflare.com/workers/framework-guides/
While you're at it, maybe it makes sense to add fastapi/django there too?
First we should merge the following workers-py PRs to make this correct: