mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-26 03:36:14 -05:00
📝 Add first tutorial src files
This commit is contained in:
15
docs/tutorial/src/tutorial11.py
Normal file
15
docs/tutorial/src/tutorial11.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: str = None
|
||||
price: float
|
||||
tax: float = None
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.put("/items/{item_id}")
|
||||
async def create_item(item_id: int, item: Item):
|
||||
return {"item_id": item_id, **item.dict()}
|
||||
Reference in New Issue
Block a user