Browse Source

📝 Add extra return fields first-steps example

Co-authored-by: Cursor <[email protected]>
pull/15640/head
Saurabh 2 weeks ago
parent
commit
3cf0c70600
  1. 10
      docs/en/docs/tutorial/first-steps.md
  2. 9
      docs_src/first_steps/tutorial004_py310.py

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

9
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"}
Loading…
Cancel
Save