You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
#!/usr/bin/env python3
|
|
"""
|
|
调试后端启动问题
|
|
"""
|
|
import sys
|
|
import os
|
|
|
|
# 添加项目路径
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), 'backend'))
|
|
|
|
try:
|
|
print("1. 测试导入数据库模块...")
|
|
from app.database import init_db, get_db
|
|
print("✓ 数据库模块导入成功")
|
|
|
|
print("2. 测试导入模型...")
|
|
from app.models import Project, Scan, Vulnerability
|
|
print("✓ 模型导入成功")
|
|
|
|
print("3. 测试导入API路由...")
|
|
from app.api import projects, scans, reports, vulnerabilities, files
|
|
print("✓ API路由导入成功")
|
|
|
|
print("4. 测试初始化数据库...")
|
|
init_db()
|
|
print("✓ 数据库初始化成功")
|
|
|
|
print("5. 测试创建FastAPI应用...")
|
|
from fastapi import FastAPI
|
|
app = FastAPI()
|
|
print("✓ FastAPI应用创建成功")
|
|
|
|
print("\n所有测试通过!后端应该可以正常启动。")
|
|
|
|
except Exception as e:
|
|
print(f"❌ 错误: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|