Files
hsa/Html/apps/__init__.py
2025-08-27 19:39:38 +08:00

35 lines
848 B
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.

import logging
from flask import Flask
from .config import Config
from .extensions import init_extensions, register_namespaces
from .views import register_blueprints
def create_app(config_object: type = Config) -> Flask:
app = Flask(__name__, template_folder="templates", static_folder="static")
app.config.from_object(config_object)
# secret_key 从 config 里来
app.secret_key = app.config["SECRET_KEY"]
# logging
app.logger.setLevel(logging.DEBUG)
register_namespaces(app)
# 1) 初始化第三方扩展db、cache、jwt、cors 等)
init_extensions(app)
# 2) 注册蓝图(把子文件暴露的蓝图统一挂到 app 上)
register_blueprints(app)
# 3) 其他钩子/命令/错误处理
@app.route("/healthz")
def healthz():
return {"status": "ok"}
return app