This repository has been archived on 2020-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
magic-app/magic_app/views.py

35 lines
920 B
Python

"""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/<app_name>", 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/<app_name>")
def status(app_name):
"""Show status of applications."""
return render_template(
"app_status.html", status="UNKNOWN", app_name=app_name
)