45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from __future__ import annotations
|
|
from flask import Flask, render_template
|
|
from datetime import datetime
|
|
|
|
# bestehende Blueprints
|
|
from .routes.structures import bp as structures_bp
|
|
from .routes.cookbook import bp as cookbook_bp
|
|
from .routes.archive import bp as archive_bp
|
|
# NEU: Blueprint-ID API
|
|
from .routes.blueprints import bp as blueprints_api_bp
|
|
|
|
def create_app() -> Flask:
|
|
app = Flask(__name__, template_folder="templates")
|
|
|
|
# Jinja-Filter für Timestamps (wird in Templates genutzt)
|
|
def fmt_ts(value):
|
|
if not value:
|
|
return ""
|
|
try:
|
|
# akzeptiert "YYYY-mm-ddTHH:MM:SS" etc.
|
|
if isinstance(value, (int, float)):
|
|
return datetime.fromtimestamp(value).strftime("%Y-%m-%d %H:%M")
|
|
s = str(value).replace("T", " ").split("+", 1)[0]
|
|
return s[:16]
|
|
except Exception:
|
|
return str(value)
|
|
app.jinja_env.filters["fmt_ts"] = fmt_ts
|
|
|
|
# Blueprints registrieren
|
|
app.register_blueprint(structures_bp)
|
|
app.register_blueprint(cookbook_bp)
|
|
app.register_blueprint(archive_bp)
|
|
app.register_blueprint(blueprints_api_bp) # <-- neu
|
|
|
|
# Home + Favicon
|
|
@app.get("/")
|
|
def home():
|
|
return render_template("index.html")
|
|
|
|
@app.get("/favicon.ico")
|
|
def _favicon():
|
|
return ("", 204)
|
|
|
|
return app
|