66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
简单的路由配置测试脚本
|
|
"""
|
|
|
|
def test_route_configurations():
|
|
"""测试路由配置是否正确"""
|
|
|
|
# 测试文件内容
|
|
test_files = {
|
|
'fastapi_app.py': [
|
|
'from routes.file_manager import router as file_manager_router',
|
|
'app.include_router(file_manager_router)'
|
|
],
|
|
'routes/file_manager.py': [
|
|
'router = APIRouter(prefix="/api/v1/file-manager"'
|
|
],
|
|
'public/admin.html': [
|
|
"const FILE_API_BASE = `${window.location.protocol}//${window.location.host}/api/v1/file-manager`"
|
|
]
|
|
}
|
|
|
|
print("🔍 检查路由配置...")
|
|
print("=" * 50)
|
|
|
|
all_good = True
|
|
|
|
for file_path, expected_lines in test_files.items():
|
|
try:
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
content = f.read()
|
|
|
|
print(f"\n📄 {file_path}:")
|
|
|
|
for expected_line in expected_lines:
|
|
if expected_line in content:
|
|
print(f" ✅ {expected_line}")
|
|
else:
|
|
print(f" ❌ 缺失: {expected_line}")
|
|
all_good = False
|
|
|
|
except FileNotFoundError:
|
|
print(f" ❌ 文件不存在: {file_path}")
|
|
all_good = False
|
|
except Exception as e:
|
|
print(f" ❌ 读取错误: {e}")
|
|
all_good = False
|
|
|
|
print("\n" + "=" * 50)
|
|
if all_good:
|
|
print("✅ 所有路由配置检查通过!")
|
|
print("📋 API 端点总结:")
|
|
print(" • 聊天API: /api/v1/chat/completions, /api/v2/chat/completions")
|
|
print(" • 文件处理: /api/v1/files/*")
|
|
print(" • 项目管理: /api/v1/projects/*")
|
|
print(" • 系统管理: /api/health, /api/v1/system/*")
|
|
print(" • 文件管理器: /api/v1/file-manager/* (新)")
|
|
print("\n📱 管理后台文件:")
|
|
print(" • public/admin.html (已更新 FILE_API_BASE)")
|
|
else:
|
|
print("❌ 发现配置问题,需要修复")
|
|
|
|
return all_good
|
|
|
|
if __name__ == "__main__":
|
|
test_route_configurations() |