mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-04 15:13:26 -04:00
📝 Update docs, add first tutorials
This commit is contained in:
20
docs/tutorial/src/all/tutorial042.py
Normal file
20
docs/tutorial/src/all/tutorial042.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Set
|
||||
|
||||
from fastapi import FastAPI
|
||||
from pydantic import BaseModel
|
||||
from starlette.status import HTTP_201_CREATED
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class Item(BaseModel):
|
||||
name: str
|
||||
description: str = None
|
||||
price: float
|
||||
tax: float = None
|
||||
tags: Set[str] = []
|
||||
|
||||
|
||||
@app.post("/items/", response_model=Item, status_code=HTTP_201_CREATED)
|
||||
async def create_item(*, item: Item):
|
||||
return item
|
||||
Reference in New Issue
Block a user