Files

1.7 KiB
Raw Permalink Blame History

id, title, type, domain, stack, tags, week
id title type domain stack tags week
python.fastapi.index FastAPI index python
fastapi
FastAPI
Web 框架
pydantic
SSE
4
5
12

FastAPI

Python AI 服务最常用的 Web 框架:基于类型标注自动做参数校验和生成 OpenAPI 文档,原生支持 async 和流式响应。你熟悉的 Express / Koa、以及本计划里的 Gin,概念都能对应上:路由 ↔ 路由,中间件 ↔ 中间件,Depends ↔ 依赖注入(Gin 里通常手动传)。

学习路线

顺序 课程 级别 预计
1 路由和参数校验:路径 / 查询 / 请求体、pydantic 模型、响应模型 基础 2 小时
2 依赖注入、鉴权、中间件和统一错误处理 进阶 3 小时
3 流式输出(SSE)、生命周期、测试和部署 进阶 3 小时

企业场景

面试题

示例代码

  • examples/chat-api:完整的流式对话 API(API Key 鉴权、请求 ID、统一错误格式、SSE、依赖替换)+ 6 个测试;模型客户端是假实现,不需要 API Key

在 16 周计划中

官方资料