"""Configuration routes — form-based config pages. Merged from Java's 19 separate config pages into grouped sections. Ported from net.i2p.router.web.helpers.Config*Helper / Config*Handler. """ from __future__ import annotations from flask import Blueprint, render_template, request, redirect, url_for, current_app bp = Blueprint("config", __name__, url_prefix="/config") _SECTIONS = {"network", "security", "ui", "tunnels", "clients", "logging", "updates", "advanced"} @bp.route("/") def config_index(): """Configuration overview — links to all sections.""" return render_template("config/index.html", sections=sorted(_SECTIONS)) @bp.route("/
", methods=["GET"]) def config_section(section: str): """Render a config section page.""" if section not in _SECTIONS: return render_template("404.html"), 404 ctx = current_app.config["CONSOLE_CONTEXT"] return render_template( f"config/{section}.html", section=section, properties=ctx.get_all_properties(), ) @bp.route("/
", methods=["POST"]) def config_save(section: str): """Save configuration changes from a form POST.""" if section not in _SECTIONS: return render_template("404.html"), 404 ctx = current_app.config["CONSOLE_CONTEXT"] for key, value in request.form.items(): ctx.set_property(key, value) return redirect(url_for("config.config_section", section=section))