#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
开发环境启动脚本
自动设置开发环境变量并启动Flask应用
"""

import os
import sys

def start_dev_server():
    """启动开发服务器"""
    print("🚀 启动开发服务器...")
    
    # 设置开发环境变量
    os.environ['FLASK_APP'] = 'app.py'
    os.environ['FLASK_ENV'] = 'development'
    os.environ['FLASK_DEBUG'] = '1'
    os.environ['PORT'] = '5001'
    
    print("📋 开发环境配置:")
    print("   - 热重载: 启用")
    print("   - 调试模式: 启用")
    print("   - 端口: 5001")
    print("   - 访问地址: http://localhost:5001")
    print()
    
    # 导入并启动应用
    try:
        from app import app
        app.run(
            host='0.0.0.0',
            port=5001,
            debug=True,
            use_reloader=True
        )
    except KeyboardInterrupt:
        print("\n👋 开发服务器已停止")
    except Exception as e:
        print(f"❌ 启动失败: {e}")
        import traceback
        traceback.print_exc()

if __name__ == '__main__':
    start_dev_server()
