"""View routing.""" from flask import Blueprint, redirect, render_template, url_for from magic_app.forms import GiteaInstallForm apps = Blueprint("apps", __name__) @apps.route("/") def listing(): return render_template("app_list.html", apps=["gitea"]) @apps.route("/install/", methods=("GET", "POST")) def install(app_name): """Install an application.""" from magic_app.tasks import install_app if app_name == "gitea": form = GiteaInstallForm() if form.validate_on_submit(): install_app.apply_async(args=[app_name, form.data]) return redirect(url_for("apps.status", app_name=app_name)) return render_template("app_install.html", app_name=app_name, form=form) @apps.route("/status/") def status(app_name): """Show status of applications.""" return render_template( "app_status.html", status="UNKNOWN", app_name=app_name )