mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-23 22:29:34 -05:00
20 lines
275 B
Python
20 lines
275 B
Python
from dataclasses import dataclass
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
@dataclass
|
|
class Item:
|
|
name: str
|
|
price: float
|
|
description: str | None = None
|
|
tax: float | None = None
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.post("/items/")
|
|
async def create_item(item: Item):
|
|
return item
|