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"} +