Spec out app interaction further
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luke Murphy 2020-06-30 21:03:58 +02:00
parent f3f4aa577d
commit 1b900c740c
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 31 additions and 3 deletions

View File

@ -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("/<app>")
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")

View File

@ -6,6 +6,11 @@
<title>Magic App</title>
</head>
<body>
Hello, World.
<p>List of apps that can be installed:</p>
<ul>
{% for app in apps %}
<li><a href="/{{ app }}">{{ app }}</a></li>
</ul>
{% endfor %}
</body>
</html>