Files
opc-manager/backend/flask_app.py
mac c12389fb89 feat: 运营模块 + 全局 Slogan + 模板热加载
- 新增运营模块(侧边栏/panel/render,7条运营思考)
- 全局 Slogan 置于顶部品牌区(蓝白 pill 标签)
- flask_app.py 启用 TEMPLATES_AUTO_RELOAD
- 项目模块状态筛选改为 Tab(已签约/待签约)
2026-07-07 13:15:54 +08:00

35 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# flask_app.py — 入口app 创建 + 蓝图注册 + 迁移 + 启动
# 拆分后仅 ~35 行,所有路由在 routes.py业务辅助在 helpers.py基础设施在 db.py
import os
import sys
# 确保 backend 目录在 sys.path 中(兼容 gunicorn --preload 模式)
_backend_dir = os.path.dirname(os.path.abspath(__file__))
if _backend_dir not in sys.path:
sys.path.insert(0, _backend_dir)
from flask import Flask
from db import ROOT # 触发 load_dotenv + 建目录
from routes import bp
from migrations import run_migrations
app = Flask(
__name__,
template_folder=str(ROOT / "templates"),
static_folder=str(ROOT / "static"),
)
app.secret_key = os.environ.get("SECRET_KEY", "opc-dev-secret-2026")
app.config["TEMPLATES_AUTO_RELOAD"] = True
app.register_blueprint(bp)
# 模块级执行迁移(保留 gunicorn --preload 行为:导入即触发)
run_migrations()
if __name__ == "__main__":
app.run(
host="127.0.0.1",
port=5177,
debug=os.environ.get("FLASK_DEBUG", "false").lower() in ("true", "1", "yes"),
)