Improve FastAPI Python docs and adds frontend example. - #32662
Open
dom96 wants to merge 1 commit into
Open
Conversation
dom96
requested review from
a team,
GregBrimble,
MattieTK,
WalshyDev,
irvinebroque,
korinne and
vy-ton
as code owners
August 11, 2026 16:18
Contributor
Review
👉 Fix in your agent 👈Fix the following review findings in PR #32662 (https://github.com/cloudflare/cloudflare-docs/pull/32662).
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 (2)
#### CR-26cc790d8ba5 · Unencoded path used in asset URL
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 143
- **Issue:** FastAPI’s `path` converter returns the URL-decoded value (e.g. `/my%20file.txt` becomes `my file.txt`). Interpolating it into `f"https://assets.local/{path}"` produces an invalid URL with a space, so `env.ASSETS.fetch(asset_url)` can fail for paths containing spaces or other encoded characters.
- **Fix:** Build the asset URL from pre-encoded data or re-encode the path, e.g. `from urllib.parse import quote` and use `f"https://assets.local/{quote(path, safe='/')}"`.
#### CR-6294191418dd · SPA fallback missing from static assets config
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 94
- **Issue:** The section describes serving an SPA and compares the setup to FastAPI’s `app.frontend()`, but the `assets` block only sets `run_worker_first`. With this config, a request for a client-side route such as `/dashboard` reaches the catch-all handler, fetches a non-existent asset, and the assets binding returns 404 instead of falling back to `index.html`.
- **Fix:** Add `"not_found_handling": "single-page-application"` to the `assets` block so the assets binding serves `index.html` for missing paths.
### Suggestions (1)
#### CR-5f9236957b63 · Forward reference to app defined later
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 128
- **Issue:** The `Default` class method calls `asgi.fetch(app, request, self.env)` while `app` is defined on line 132, after the class. Python resolves the name at call time, so this currently works, but it is fragile and confusing if the module is reorganized.
- **Fix:** Move the `app = FastAPI()` and route definitions above the `Default` Worker class so dependencies are defined before they are referenced.
---
## Style Guide Review
### Warnings (2)
#### SG-ccda99307cf5 · Use WranglerConfig component for Wrangler configuration
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 47
- **Issue:** Raw ` ```jsonc ` block contains Wrangler keys (`name`, `main`, `compatibility_date`).
- **Fix:** Replace this block with the `<WranglerConfig>` component.
#### SG-66a5fdcc726a · Use WranglerConfig component for Wrangler configuration
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 88
- **Issue:** Raw ` ```jsonc title="wrangler.jsonc" ` block contains Wrangler keys (`name`, `main`, `compatibility_date`).
- **Fix:** Replace this block with the `<WranglerConfig>` component.
### Suggestions (1)
#### SG-49e105ecc63b · Headings should use sentence case
- **File:** `src/content/docs/workers/languages/python/packages/fastapi.mdx` line 24
- **Issue:** Body heading `## Quick Start` uses title case.
- **Fix:** Change to `## Quick start`.
Code ReviewThis code review is in beta and may not always be helpful — use your judgment. Warnings (2)
Suggestions (1)
ConventionsNo convention issues found. Style Guide ReviewWarnings (2)
Suggestions (1)
CommandsOnly codeowners can run commands. Post a comment with the command to trigger it.
|
Contributor
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
Contributor
|
Preview URL: https://da398a93.preview.developers.cloudflare.com Files with changes (up to 15) |
ryanking13
reviewed
Aug 12, 2026
dom96
force-pushed
the
dominik/fastapi-better-docs
branch
from
August 12, 2026 14:41
4611991 to
779f943
Compare
dom96
force-pushed
the
dominik/fastapi-better-docs
branch
from
August 12, 2026 14:43
779f943 to
da398a9
Compare
ryanking13
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adjustments to our FastAPI docs to include better getting started section and example showing how to serve static files.