FastAPI 默认返回 JSON(序列化 dicts、lists 和 Pydantic 模型),但它通过 fastapi.responses 类支持许多其他响应类型以满足不同的需求 — HTML、文件、流、重定向和纯文本。
默认和常见响应类
python
fastapi.responses (
JSONResponse, HTMLResponse, PlainTextResponse,
RedirectResponse, FileResponse, StreamingResponse,
)
(): {: }
():
():
(): RedirectResponse(url=)
