task_auto_plan/README.md

48 lines
953 B
Markdown
Raw Normal View History

2026-04-24 09:13:51 +00:00
# 单体示例工程
2026-04-23 09:01:52 +00:00
2026-04-24 09:13:51 +00:00
一个基于 FastAPI 的简单待办事项Todo管理服务使用内存假数据存储。
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
## 功能
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
- 获取所有待办事项列表
- 根据 ID 获取单个待办事项
- 创建新的待办事项
- 更新待办事项
- 删除待办事项
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
## 安装依赖
2026-04-24 07:17:55 +00:00
```bash
2026-04-24 09:13:51 +00:00
cd codegen-runs/codegen_a2cef5070965479b93c5b3c07d4c8216
pip install -r requirements.txt
```
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
## 启动服务
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
```bash
uvicorn app.main:app --reload --port 8000
2026-04-24 07:17:55 +00:00
```
2026-04-24 09:13:51 +00:00
访问 http://127.0.0.1:8000/docs 查看自动生成的 API 文档Swagger UI
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
## 运行测试
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
```bash
cd codegen-runs/codegen_a2cef5070965479b93c5b3c07d4c8216
pytest tests/ -v
```
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
## 快速验证
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
启动服务后,在另一个终端执行:
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
```bash
# 获取所有待办事项
curl http://127.0.0.1:8000/todos
2026-04-24 07:17:55 +00:00
2026-04-24 09:13:51 +00:00
# 创建新待办事项
curl -X POST http://127.0.0.1:8000/todos \
-H "Content-Type: application/json" \
-d '{"title": "学习 FastAPI", "completed": false}'
```