mirror of
https://github.com/fastapi/fastapi.git
synced 2026-11-21 10:13:53 +08:00
24 lines
467 B
Python
24 lines
467 B
Python
from typing import Annotated
|
|
|
|
from fastapi import FastAPI, Form
|
|
from pydantic import BaseModel
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class Profile(BaseModel):
|
|
name: str
|
|
|
|
|
|
class Preferences(BaseModel):
|
|
tags: list[str] = []
|
|
|
|
|
|
@app.post("/profiles/")
|
|
async def create_profile(
|
|
profile: Annotated[Profile, Form()],
|
|
preferences: Annotated[Preferences, Form()],
|
|
token: Annotated[str, Form()],
|
|
):
|
|
return {"profile": profile, "preferences": preferences, "token": token}
|