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
2020-07-05 02:41:06 +02:00

45 lines
1.2 KiB
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])
return redirect(url_for("apps.status", app_name=app_name))
return render_template("app_install.html", app_name=app_name, form=form)
@apps.route("/install-test/<app_name>")
def install_test(app_name):
"""Development aid to quickly test installation logic."""
from magic_app.tasks import install_app
install_app.apply_async(args=[app_name])
return f"<a href='{app_name}'>Try again?</a>"
@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
)