From 3cf0c70600a31a9d01dd820db9577f3339513cdd Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 29 May 2026 15:52:59 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20extra=20return=20fields=20?= =?UTF-8?q?first-steps=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- docs/en/docs/tutorial/first-steps.md | 10 ++++++++++ docs_src/first_steps/tutorial004_py310.py | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 docs_src/first_steps/tutorial004_py310.py diff --git a/docs/en/docs/tutorial/first-steps.md b/docs/en/docs/tutorial/first-steps.md index b11775437d..898b9027a0 100644 --- a/docs/en/docs/tutorial/first-steps.md +++ b/docs/en/docs/tutorial/first-steps.md @@ -66,6 +66,16 @@ You will see the JSON response as: {"message": "Hello World"} ``` +To return additional fields, update your app to the following: + +{* ../../docs_src/first_steps/tutorial004_py310.py *} + +Then you will see a JSON response like: + +```JSON +{"message": "Hello World", "status": "ok"} +``` + ### Interactive API docs { #interactive-api-docs } Now go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs). diff --git a/docs_src/first_steps/tutorial004_py310.py b/docs_src/first_steps/tutorial004_py310.py new file mode 100644 index 0000000000..f000f0c744 --- /dev/null +++ b/docs_src/first_steps/tutorial004_py310.py @@ -0,0 +1,9 @@ +from fastapi import FastAPI + +app = FastAPI() + + +@app.get("/") +async def root(): + return {"message": "Hello World", "status": "ok"} +