init:测试

This commit is contained in:
张鑫
2025-10-28 14:36:59 +08:00
parent 3beef97888
commit 7691f52f15
11 changed files with 1636 additions and 0 deletions

81
README copy.md Normal file
View File

@@ -0,0 +1,81 @@
# FastAPI 示例应用
这是一个使用uv管理的FastAPI示例应用。
## 安装和运行
### 使用uv推荐
1. 初始化项目:
```bash
uv init
```
2. 安装依赖:
```bash
uv sync
```
3. 启动开发服务器:
```bash
uv run uvicorn app.main:app --reload --host 0.0.0.0
```
### 使用pip
1. 安装依赖:
```bash
pip install -r requirements.txt
```
2. 启动开发服务器:
```bash
uvicorn app.main:app --reload
```
### 使用Docker
1. 构建并启动:
```bash
docker-compose up --build
```
2. 访问应用http://localhost:8000
## API文档
启动服务器后访问以下地址查看API文档
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## API端点
### 基础端点
- `GET /` - 欢迎信息
- `GET /health` - 健康检查
### 商品管理API
- `GET /api/v1/items` - 获取所有商品
- `GET /api/v1/items/{item_id}` - 获取指定商品
- `POST /api/v1/items` - 创建新商品
- `PUT /api/v1/items/{item_id}` - 更新商品
- `DELETE /api/v1/items/{item_id}` - 删除商品
## 项目结构
```
├── app/
│ ├── __init__.py
│ ├── main.py # FastAPI应用主文件
│ └── routes/
│ ├── __init__.py
│ └── items.py # 商品管理API路由
├── .dockerignore # Docker构建忽略文件
├── .gitignore # Git忽略文件
├── Dockerfile # Docker镜像配置
├── docker-compose.yml # Docker编排配置
├── pyproject.toml # uv项目配置
├── requirements.txt # Python依赖
└── README.md # 项目说明
```