Files
pkm/app/__init__.py
2025-08-18 20:14:56 +02:00

36 lines
1010 B
Python

from flask import Flask
from .config import load_config
from .services.vault import Vault
def create_app(config_override=None) -> Flask:
app = Flask(
__name__,
static_folder="static",
template_folder="templates",
)
cfg = config_override or load_config()
app.config["KB_VAULT_PATH"] = cfg.VAULT_PATH
app.config["SECRET_KEY"] = cfg.SECRET_KEY
app.config["DEBUG"] = cfg.DEBUG
# Ensure vault structure early if configured
if cfg.VAULT_PATH:
try:
Vault(cfg.VAULT_PATH).ensure_structure()
except Exception:
# Avoid crashing on startup; routes can surface errors as needed
pass
# Register blueprints
from .routes.home import bp as home_bp
from .routes.notes import bp as notes_bp
app.register_blueprint(home_bp)
app.register_blueprint(notes_bp)
@app.get("/healthz")
def healthz():
return {"status": "ok", "vault": app.config.get("KB_VAULT_PATH")}, 200
return app