#!/usr/bin/env python3 """ 项目服务管理面板 - 主入口 模块化重构版本 v3.4.0 """ from flask import Flask from config import APP_NAME, APP_VERSION, APP_PORT from database import init_db, close_db from utils import log_message from routes_cron import register_cron_routes from routes_system import register_system_routes from routes_config import register_config_routes from routes_email import register_email_routes from routes_project import register_project_routes from routes_docker import register_docker_routes from routes_discovery import register_discovery_routes from templates import get_html_template # 创建 Flask 应用 app = Flask(__name__) def init_app(): """初始化应用""" # 注册数据库钩子 app.teardown_appcontext(close_db) # 注册路由 register_cron_routes(app) register_system_routes(app) register_config_routes(app) register_email_routes(app) register_project_routes(app) register_docker_routes(app) register_discovery_routes(app) # 主页路由 @app.route('/') def index(): return get_html_template() # 初始化数据库 init_db() log_message(f"{APP_NAME} {APP_VERSION} 初始化完成") if __name__ == '__main__': init_app() log_message(f"启动 {APP_NAME},端口: {APP_PORT}") app.run(host='0.0.0.0', port=APP_PORT, debug=False)