Skip to content

Add flask in Python workers documentation - #33074

Open
hoodmane wants to merge 1 commit into
productionfrom
hoodmane/flask-docs
Open

Add flask in Python workers documentation#33074
hoodmane wants to merge 1 commit into
productionfrom
hoodmane/flask-docs

Conversation

@hoodmane

@hoodmane hoodmane commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

First we should merge the following workers-py PRs to make this correct:

@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review

⚠️ 6 warnings found in commit aad1ee9.

👉 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 Review

This code review is in beta and may not always be helpful — use your judgment.

Warnings (3)
File Issue
workers/languages/python/packages/flask.mdx line 109 Incorrect framework name — 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.
workers/languages/python/packages/fastapi.mdx line 90 Incorrect example response — 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.
workers/languages/python/packages/fastapi.mdx line 167 Unsafe header passthrough — 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)
File Issue
PR Description explains the work — 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.
PR Scope accuracy — 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)
File Issue
workers/languages/python/packages/flask.mdx line 109 Incorrect framework name in prose — Line 109 says "This ensures every request reaches your FastAPI Worker first" in a Flask guide. Fix: Change "FastAPI Worker" to "Flask Worker".
Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.
/disable-auto-review Stops automatic reviews from triggering on future pushes to this PR. Codeowners can still run /review or /full-review manually.
/rebase Rebases the PR branch against production. On conflict, attempts to resolve automatically using AI. Stops with an explanation if confidence is not high enough.

@github-actions github-actions Bot added product:workers Related to Workers product size/m labels Aug 27, 2026
def index():
return {"message": "Hello from Flask"}

Default = wsgi.entrypoint(app)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/workers/ @cloudflare/workers-docs, @GregBrimble, @irvinebroque, @mikenomitch, @korinne, @WalshyDev, @cloudflare/deploy-config, @cloudflare/product-owners, @cloudflare/wrangler, @MattieTK, @cloudflare/dev-plat-leads, @vy-ton, @cloudflare/workers-runtime-1

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 27, 2026

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://hoodmane-flask-docs.previews.developers.cloudflare.com (commit aad1ee9)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://6e8c1c3a.previews.developers.cloudflare.com aad1ee9 2026-08-28T00:04:43.913Z Visit the dashboard ↗

return Response(
body,
status=asset_response.status,
headers=asset_response.headers,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Worker returns:

```json output
{"message":"Hello from Flask"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{"message":"Hello from Flask"}
{"Hello": "World"}

Comment on lines +163 to +165
`run_sync` bridges both asynchronous asset operations into Flask's synchronous
handler. API routes take priority, and unmatched paths are served from
`./public/`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think those are confusing because they are not normally reentrant.

Comment on lines +168 to +170
## More examples

Run the Flask todo example from the `python-workers-examples` repository.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Comment on lines +23 to +25
## Prerequisites

You need [`uv`](https://docs.astral.sh/uv/) and [`node`](https://nodejs.org/) installed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product:workers Related to Workers product size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants