diff --git a/magic_app/app.py b/magic_app/app.py index 390b601..cf5bf96 100644 --- a/magic_app/app.py +++ b/magic_app/app.py @@ -1,17 +1,40 @@ +from json import loads +from pathlib import Path + from flask import Flask, render_template, send_from_directory app = Flask(__name__) +def get_apps(): + """All apps that can be installed.""" + apps_path = (Path(app.root_path) / "static" / "apps.json").absolute() + + try: + with open(apps_path, "r") as handle: + return [key for key in loads(handle.read())] + except Exception as exception: + print("Failed to load apps.json, saw {}".format(str(exception))) + + @app.route("/") def home(): - return render_template("index.html") + apps = get_apps() + return render_template("index.html", apps=apps) @app.route("/apps") -def apps(): +def apps_list(): return send_from_directory("static", "apps.json") +@app.route("/") +def app_config(app_name): + # TODO(decentral1se): clone the app repository to somewhere under /tmp read + # all the env vars, secrets, etc. and fire up a wtform and deploy button + # using a new app.html template in the templates directory + pass + + if __name__ == "__main__": app.run(host="0.0.0.0") diff --git a/magic_app/templates/index.html b/magic_app/templates/index.html index 2ffd83b..3365ddd 100644 --- a/magic_app/templates/index.html +++ b/magic_app/templates/index.html @@ -6,6 +6,11 @@ Magic App - Hello, World. +

List of apps that can be installed:

+ + {% endfor %}