mirror of
https://github.com/fastapi/fastapi.git
synced 2026-11-26 19:53:17 +08:00
🚚 Re-sort tutorial example files
This commit is contained in:
@@ -1,24 +1,11 @@
|
||||
from fastapi import Body, FastAPI, Path, Query
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
from pydantic.types import EmailStr
|
||||
from pydantic.types import UrlStr
|
||||
from typing import Set, List
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class UserIn(BaseModel):
|
||||
username: str
|
||||
password: str
|
||||
email: EmailStr
|
||||
full_name: str = None
|
||||
|
||||
|
||||
class UserOut(BaseModel):
|
||||
username: str
|
||||
email: EmailStr
|
||||
full_name: str = None
|
||||
|
||||
|
||||
@app.post("/user/", response_model=UserOut)
|
||||
async def create_user(*, user: UserIn):
|
||||
return user
|
||||
@app.get("/items/")
|
||||
async def read_items(*, strange_header: str = Header(None, convert_underscores=False)):
|
||||
return {"strange_header": strange_header}
|
||||
|
||||
Reference in New Issue
Block a user