初次提交
This commit is contained in:
174
backend/README_8080_START.md
Normal file
174
backend/README_8080_START.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# 云盘应用端口8080启动和测试指南
|
||||
|
||||
## 🚀 快速启动
|
||||
|
||||
### 方法1:自动启动并测试(推荐)
|
||||
```bash
|
||||
cd backend
|
||||
chmod +x start_and_test_8080.sh
|
||||
./start_and_test_8080.sh
|
||||
```
|
||||
|
||||
### 方法2:手动启动
|
||||
```bash
|
||||
cd backend
|
||||
|
||||
# 1. 启动服务器
|
||||
python3 start_8080.py
|
||||
|
||||
# 2. 在另一个终端测试API
|
||||
python3 test_api_8080.py
|
||||
```
|
||||
|
||||
### 方法3:自动模式
|
||||
```bash
|
||||
cd backend
|
||||
python3 start_8080.py --auto
|
||||
```
|
||||
|
||||
## 📋 测试的API端点
|
||||
|
||||
### 基础端点
|
||||
- `GET /` - 根路径
|
||||
- `GET /health` - 健康检查
|
||||
- `GET /api/v1/health` - API健康检查
|
||||
- `GET /docs` - Swagger API文档
|
||||
- `GET /redoc` - ReDoc文档
|
||||
- `GET /openapi.json` - OpenAPI规范
|
||||
|
||||
### 认证端点
|
||||
- `POST /api/v1/auth/register` - 用户注册
|
||||
- `POST /api/v1/auth/token` - 用户登录
|
||||
|
||||
### 文件端点
|
||||
- `GET /api/v1/files` - 文件列表
|
||||
- `POST /api/v1/files/upload` - 文件上传
|
||||
|
||||
## 🔧 环境要求
|
||||
|
||||
- Python 3.8+
|
||||
- 依赖包:见 `requirements_8080.txt`
|
||||
|
||||
## 📦 安装依赖
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
pip install -r requirements_8080.txt
|
||||
```
|
||||
|
||||
## 🌐 访问地址
|
||||
|
||||
启动成功后,可以通过以下地址访问:
|
||||
|
||||
- **本地访问**: http://localhost:8080
|
||||
- **API文档**: http://localhost:8080/docs
|
||||
- **健康检查**: http://localhost:8080/api/v1/health
|
||||
|
||||
## 🧪 测试命令
|
||||
|
||||
### 测试所有端点
|
||||
```bash
|
||||
python3 test_api_8080.py
|
||||
```
|
||||
|
||||
### 测试特定端点类型
|
||||
```bash
|
||||
# 只测试基础端点
|
||||
python3 test_api_8080.py --basic
|
||||
|
||||
# 只测试认证端点
|
||||
python3 test_api_8080.py --auth
|
||||
|
||||
# 只测试文件端点
|
||||
python3 test_api_8080.py --files
|
||||
```
|
||||
|
||||
### 指定不同的API地址
|
||||
```bash
|
||||
python3 test_api_8080.py --url http://192.168.1.100:8080
|
||||
```
|
||||
|
||||
### 启动前等待时间
|
||||
```bash
|
||||
python3 test_api_8080.py --wait 5 # 等待5秒后开始测试
|
||||
```
|
||||
|
||||
## 📊 测试结果说明
|
||||
|
||||
- ✅ **成功**: 端点正常响应
|
||||
- 🔌 **连接失败**: 无法连接到服务器
|
||||
- ⏰ **超时**: 请求超时
|
||||
- ❌ **其他错误**: 各种错误情况
|
||||
|
||||
## 🔍 故障排除
|
||||
|
||||
### 端口被占用
|
||||
```bash
|
||||
# 查看占用端口的进程
|
||||
lsof -i :8080
|
||||
|
||||
# 停止进程
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
### 依赖问题
|
||||
```bash
|
||||
# 安装基础依赖
|
||||
pip install fastapi uvicorn requests
|
||||
|
||||
# 或安装所有依赖
|
||||
pip install -r requirements_8080.txt
|
||||
```
|
||||
|
||||
### 模块导入错误
|
||||
如果遇到模块导入错误,脚本会自动切换到简化模式,提供基础的API功能。
|
||||
|
||||
## 🎯 预期结果
|
||||
|
||||
正常运行时,你应该看到:
|
||||
|
||||
1. **服务器启动信息**
|
||||
```
|
||||
🚀 启动云盘应用服务...
|
||||
📍 本地访问:
|
||||
根路径: http://localhost:8080
|
||||
API文档: http://localhost:8080/docs
|
||||
```
|
||||
|
||||
2. **API测试结果**
|
||||
```
|
||||
🧪 开始API测试 - 端口8080
|
||||
📊 测试报告
|
||||
总测试数: 6
|
||||
成功: 6
|
||||
失败: 0
|
||||
成功率: 100.0%
|
||||
🎉 所有测试通过!API服务运行正常
|
||||
```
|
||||
|
||||
3. **API响应示例**
|
||||
```json
|
||||
{
|
||||
"message": "云盘应用 API",
|
||||
"version": "1.0.1",
|
||||
"docs": "/docs",
|
||||
"health": "/api/v1/health"
|
||||
}
|
||||
```
|
||||
|
||||
## 📞 使用curl测试
|
||||
|
||||
你也可以使用curl命令直接测试:
|
||||
|
||||
```bash
|
||||
# 测试根路径
|
||||
curl http://localhost:8080/
|
||||
|
||||
# 测试健康检查
|
||||
curl http://localhost:8080/api/v1/health
|
||||
|
||||
# 测试API文档
|
||||
curl -I http://localhost:8080/docs
|
||||
```
|
||||
|
||||
现在你可以选择任何一种方式启动和测试你的云盘应用在端口8080上!
|
||||
Reference in New Issue
Block a user