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
Luke Murphy 7fe5c23c58
All checks were successful
continuous-integration/drone/push Build is passing
Drop testing end-point and thread form data
2020-07-05 02:51:17 +02:00

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
)