#!/usr/bin/env python3
"""
后端服务启动脚本
"""

import sys
import os

# 添加backend目录到Python路径
backend_dir = os.path.dirname(os.path.abspath(__file__))
if backend_dir not in sys.path:
    sys.path.insert(0, backend_dir)

try:
    import uvicorn
    from api.ai_swap_api import app
    
    print("=" * 50)
    print("AI Swap 后端服务启动中...")
    print("=" * 50)
    print(f"服务地址: http://localhost:8000")
    print(f"API文档: http://localhost:8000/docs")
    print(f"健康检查: http://localhost:8000/health")
    print("=" * 50)
    
    # 启动服务
    uvicorn.run(
        "backend.api.ai_swap_api:app",
        host="0.0.0.0",
        port=8000,
        reload=True,
        log_level="info"
    )
    
except ImportError as e:
    print(f"错误: 缺少依赖 - {e}")
    print("请运行: pip install fastapi uvicorn python-multipart")
    sys.exit(1)
except Exception as e:
    print(f"启动失败: {e}")
    sys.exit(1) 