init:测试
This commit is contained in:
81
README copy.md
Normal file
81
README copy.md
Normal 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 # 项目说明
|
||||
```
|
||||
Reference in New Issue
Block a user