2026-05-19 03:01:30 +00:00
|
|
|
# Simple Hello API
|
2026-05-14 07:53:55 +00:00
|
|
|
|
2026-05-19 03:01:30 +00:00
|
|
|
一个最简单的 FastAPI 单体示例工程。
|
2026-05-14 08:04:47 +00:00
|
|
|
|
|
|
|
|
## 安装依赖
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
pip install -r requirements.txt
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 启动服务
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
uvicorn app.main:app --reload --port 8000
|
|
|
|
|
```
|
|
|
|
|
|
2026-05-19 03:01:30 +00:00
|
|
|
启动后访问 http://127.0.0.1:8000/docs 查看 Swagger 文档。
|
2026-05-14 08:04:47 +00:00
|
|
|
|
2026-05-19 03:01:30 +00:00
|
|
|
## 测试
|
2026-05-14 08:04:47 +00:00
|
|
|
|
|
|
|
|
```bash
|
2026-05-19 03:01:30 +00:00
|
|
|
pytest tests/ -v
|
2026-05-14 08:04:47 +00:00
|
|
|
```
|
|
|
|
|
|
2026-05-19 03:01:30 +00:00
|
|
|
## API 接口
|
2026-05-14 08:04:47 +00:00
|
|
|
|
2026-05-19 03:01:30 +00:00
|
|
|
- `GET /` - 返回欢迎信息
|
|
|
|
|
- `GET /hello/{name}` - 返回个性化问候
|