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