mirror of
https://github.com/fastapi/fastapi.git
synced 2026-11-23 01:48:43 +08:00
18 lines
315 B
Python
18 lines
315 B
Python
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: str = Form(),
|
|
profile: Profile | None = Form(default=None),
|
|
):
|
|
return {"token": token, "profile": profile}
|