- 后端服务: 运行中 (端口 5001)
- 数据库: SQLite (开发模式)
- 管理员账号: admin / admin123
- 主页: http://localhost:5001
- API 基础路径: http://localhost:5001/api
curl -X POST http://localhost:5001/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}'响应:
{
"message": "Login successful",
"user": {
"id": 1,
"username": "admin"
}
}curl -X GET http://localhost:5001/api/tasks/ \
-b cookies.txt响应:
{
"tasks": []
}curl -X POST http://localhost:5001/api/tasks/ \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{
"name": "测试压力测试任务",
"task_type": "perf_test",
"config": "{\"url\":\"https://tokensea.ai\",\"api_key\":\"test-key\",\"model\":\"Qwen2.5-0.5B-Instruct\",\"parallel\":8,\"number\":50}",
"schedule_type": "manual",
"is_enabled": false
}'响应:
{
"message": "Task created successfully",
"task": {
"id": 1,
"name": "测试压力测试任务",
"task_type": "perf_test",
"status": "idle"
}
}curl -X GET http://localhost:5001/api/results/statistics \
-b cookies.txt响应:
{
"total_tasks": 1,
"enabled_tasks": 0,
"running_tasks": 0,
"total_perf_results": 0,
"total_quality_results": 0
}- ✅ 数据库配置: 使用 SQLite 替代 MySQL(开发环境)
- ✅ User 模型: 添加 UserMixin 继承以支持 Flask-Login
- ✅ 端口冲突: 从 5000 改为 5001
使用 curl 或 Postman 测试 API:
# 登录并保存 cookie
curl -X POST http://localhost:5001/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}' \
-c cookies.txt
# 查看任务列表
curl -X GET http://localhost:5001/api/tasks/ -b cookies.txt
# 创建新任务
curl -X POST http://localhost:5001/api/tasks/ \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"name":"我的任务","task_type":"perf_test","config":"{\"url\":\"https://api.example.com\",\"api_key\":\"sk-xxx\",\"model\":\"gpt-3.5-turbo\",\"parallel\":8,\"number\":50}","schedule_type":"manual","is_enabled":false}'如果需要完整的前端界面:
cd frontend
npm install
npm run build然后访问 http://localhost:5001 即可看到完整的管理界面。
前端开发服务器:
cd frontend
npm install
npm run dev访问 http://localhost:3000(前端会自动代理到后端 5001)
- 位置:
backend/backend.db - 类型: SQLite
- 表结构: 已创建 4 个表
- users (用户表)
- tasks (任务表)
- perf_test_results (压力测试结果表)
- quality_test_results (质量测试结果表)
# 查看日志
tail -f app.log
# 停止服务
kill <PID>
# 重启服务
python3 run.py
# 初始化数据库
python3 init_db.py- POST /api/auth/login - 登录
- POST /api/auth/logout - 登出
- GET /api/auth/me - 获取当前用户
- POST /api/auth/change-password - 修改密码
- GET /api/tasks/ - 获取任务列表
- GET /api/tasks/ - 获取任务详情
- POST /api/tasks/ - 创建任务
- PUT /api/tasks/ - 更新任务
- DELETE /api/tasks/ - 删除任务
- POST /api/tasks//run - 执行任务
- POST /api/tasks//stop - 停止任务
- GET /api/results/perf - 获取压力测试结果
- GET /api/results/quality - 获取质量测试结果
- GET /api/results/statistics - 获取统计信息
- 使用 Postman 或 curl 测试所有 API
- 创建几个测试任务(压力测试和质量测试)
- 手动执行任务查看结果
- 查询结果验证数据保存
- 当前使用 SQLite 数据库,适合开发测试
- 生产环境建议切换到 MySQL(修改 .env 配置)
- 前端需要构建才能看到完整界面
- API Key 等敏感信息请妥善保管
所有核心功能已验证正常工作,可以开始使用 API 进行测试了!