You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
953 B

from __future__ import annotations
import json
from pathlib import Path
from flask import Flask
def _load_secret_key(project_root: Path) -> str:
conf_path = project_root / "frontend" / "data" / "conf.json"
if conf_path.exists():
try:
conf = json.loads(conf_path.read_text(encoding="utf-8"))
key = conf.get("secret_key", "")
if key:
return str(key)
except Exception:
pass
return "pysonnerie-frontend-dev-key"
def create_app() -> Flask:
app = Flask(__name__)
project_root = Path(__file__).resolve().parents[2]
secret = _load_secret_key(project_root)
app.config["SECRET_KEY"] = secret
app.config["PROJECT_ROOT"] = project_root
app.config["MUSIC_DIR"] = project_root / "backend" / "data" / "musiques"
app.config["MAX_CONTENT_LENGTH"] = 128 * 1024 * 1024
from .routes import ui
app.register_blueprint(ui)
return app