aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorKaran Jayachandra <karan.jayachandra@nxp.com>2024-04-05 17:44:16 +0200
committerKaran Jayachandra <karan.jayachandra@nxp.com>2024-04-05 17:44:16 +0200
commit2b264abdf62822936e3510b0f9690ba1e359a9b8 (patch)
treea2dfaa6cfb90ff416b1665dbf863c48e726c2b92 /app.py
parent9ef7d95c7010351078a929f5144f5098d4142cd0 (diff)
Added a basic version using flask and jinja
Diffstat (limited to 'app.py')
-rw-r--r--app.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..6ff3b9a
--- /dev/null
+++ b/app.py
@@ -0,0 +1,55 @@
+from dash import Dash
+from pathlib import PurePath
+from importlib.resources import files
+from match_up.model import PlaySession
+from match_up.view import MainLayout
+from match_up.tests import (
+ TEST_DATABASE_LOCATION,
+)
+from dash_bootstrap_components.themes import ZEPHYR
+from flask import Flask, render_template
+
+DATABASE_LOCATION = "storage.json"
+
+
+# class Application:
+# def __init__(self, debug=False):
+# self._debug = debug
+# if debug:
+# database_location = TEST_DATABASE_LOCATION
+# else:
+# database_location = DATABASE_LOCATION
+# self._session = PlaySession(PurePath(database_location))
+# self._dashboard = Dash("Match Up!", external_stylesheets=[ZEPHYR])
+# self._layout = MainLayout(
+# self._session.data.get_players(), self._session.get_matches()
+# )
+# self._dashboard.layout = self._layout.get()
+
+# def run(self):
+# self._dashboard.run(debug=self._debug)
+
+
+# def main():
+# a = Application(debug=True)
+# a.run()
+
+
+app = Flask("Match Up")
+session = PlaySession(PurePath("test_storage.json"))
+base_template_path = "match_up.templates"
+
+
+@app.route("/")
+def home():
+ print(files(base_template_path).joinpath("index.html").name)
+ return render_template(
+ "index.html",
+ player_list=session.data.get_players(),
+ game_list=session.get_matches(),
+ )
+
+
+if __name__ == "__main__":
+ print("Starting app")
+ app.run(host="localhost", debug=True, port=80)