mirror of
https://github.com/fastapi/fastapi.git
synced 2026-10-25 03:09:50 -04:00
19 lines
311 B
Python
19 lines
311 B
Python
from pydantic import BaseModel
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
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()}
|