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 if cfg.VAULT_PATH: try: Vault(cfg.VAULT_PATH).ensure_structure() except Exception: pass # Register blueprints from .routes.home import bp as home_bp from .routes.notes import bp as notes_bp from .routes.attachments import bp as attachments_bp # ensure attachments is registered app.register_blueprint(home_bp) app.register_blueprint(notes_bp) app.register_blueprint(attachments_bp) @app.get("/healthz") def healthz(): return {"status": "ok", "vault": app.config.get("KB_VAULT_PATH")}, 200 return app