From 8ca62a5c817c7f673b6075ab6a75ad8226c2d838 Mon Sep 17 00:00:00 2001 From: Susan Irene <96124849+susansuhayl2004@users.noreply.github.com> Date: Mon, 4 May 2026 19:03:22 +0530 Subject: [PATCH] Added a small explanation to improve clarity for the basic FastAPI example. Changes Explained how @app.get("/") works Clarified function execution Explained automatic JSON response Reason This helps beginners better understand how routing works in FastAPI. --- docs/en/docs/index.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/en/docs/index.md b/docs/en/docs/index.md index 026961e25a..0afd83cd82 100644 --- a/docs/en/docs/index.md +++ b/docs/en/docs/index.md @@ -226,6 +226,13 @@ app = FastAPI() async def read_root(): return {"Hello": "World"} +#### Explanation + +- `@app.get("/")` defines an HTTP GET endpoint for the root URL (`/`) +- When a client accesses this URL, the function `read_root()` is executed +- The returned dictionary is automatically converted into a JSON response + +This shows how FastAPI maps routes directly to Python functions. @app.get("/items/{item_id}") async def read_item(item_id: int, q: str | None = None):