mirror of https://github.com/tiangolo/fastapi.git
17 lines
317 B
Python
17 lines
317 B
Python
from fastapi import FastAPI, Form
|
|
from pydantic import BaseModel
|
|
from typing_extensions import Annotated
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
class FormData(BaseModel):
|
|
username: str
|
|
password: str
|
|
model_config = {"extra": "forbid"}
|
|
|
|
|
|
@app.post("/login/")
|
|
async def login(data: Annotated[FormData, Form()]):
|
|
return data
|