modified: app/__init__.py

This commit is contained in:
SimolZimol
2026-08-07 21:34:40 +02:00
parent afa6359bf5
commit d559081345

View File

@@ -5,9 +5,17 @@ from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy() db = SQLAlchemy()
# Die Templates/Static-Verzeichnisse liegen auf Repo-Ebene (neben dem app/ Paket),
# nicht innerhalb des Pakets. Daher relativ zur Repo-Wurzel (Ueberverzeichnis) aufloesen.
_REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
def create_app(): def create_app():
app = Flask(__name__) app = Flask(
__name__,
template_folder=os.path.join(_REPO_ROOT, "templates"),
static_folder=os.path.join(_REPO_ROOT, "static"),
)
# Konfiguration aus Umgebungsvariablen (Coolify) # Konfiguration aus Umgebungsvariablen (Coolify)
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", "dev-secret-key") app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", "dev-secret-key")
@@ -29,6 +37,8 @@ def create_app():
from . import routes # noqa: F401 from . import routes # noqa: F401
app.register_blueprint(routes.bp)
with app.app_context(): with app.app_context():
db.create_all() db.create_all()
# Seed (idempotent) beim Start, damit die App sofort funktioniert # Seed (idempotent) beim Start, damit die App sofort funktioniert