Skip to content

Instantly share code, notes, and snippets.

@vndee
Created October 19, 2022 08:18
Show Gist options
  • Save vndee/6c17af9d142361c40d91c510e21f69b9 to your computer and use it in GitHub Desktop.
Save vndee/6c17af9d142361c40d91c510e21f69b9 to your computer and use it in GitHub Desktop.
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: float
quantity: int
@app.put("/update/{item_id}")
async def update_item(item_id: int, item: Item) -> Response:
return JSONResponse({
"item_id": item_id,
"item_name": item.name,
"item_price": item.price,
"item_quantity": item.quantity
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment