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