Browse Source

Move tutorial example to .py with response_model and proper location

pull/14121/head
msrajput08 10 months ago
parent
commit
1311952a53
  1. 18
      docs_src/tutorial/first_steps_example.py

18
docs_src/tutorial/first_steps_example.py

@ -0,0 +1,18 @@
from typing import List
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
name: str
description: str = None
price: float
tax: float = None
@app.get("/items/", response_model=List[Item])
async def read_items():
return [
{"name": "Item 1", "description": "Desc 1", "price": 10.0, "tax": 0.5},
{"name": "Item 2", "description": "Desc 2", "price": 20.0, "tax": 1.0},
]
Loading…
Cancel
Save