mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-06 10:36:39 +00:00
20 lines
309 B
Python
20 lines
309 B
Python
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
@dataclass
|
|
class Item:
|
|
name: str
|
|
price: float
|
|
description: Optional[str] = None
|
|
tax: Optional[float] = None
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.post("/items/")
|
|
async def create_item(item: Item):
|
|
return item
|