"""GET/POST /settings - notification backend configuration, plus a send-test-notification action.""" from flask import Blueprint, redirect, render_template, request, url_for import models import notifier bp = Blueprint("settings", __name__) FORM_FIELDS = ["ntfy_server_url", "ntfy_topic", "ntfy_auth_token", "daily_run_time"] @bp.route("/settings", methods=["GET", "POST"]) def settings(): message = None if request.method == "POST": if request.form.get("action") == "test": notifier.get_notifier().send( title="Test notification", body="This is a test notification from boarding-pass-pipeline.", url=None, ) message = "Test notification sent." else: for f in FORM_FIELDS: if f in request.form: models.set_setting(f, request.form[f].strip()) message = "Settings saved." return render_template("settings.html", settings=models.get_all_settings(), message=message)