summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app.py55
-rw-r--r--src/match_up/__init__.py63
-rw-r--r--src/match_up/templates/index.html3
-rw-r--r--templates/index.html51
4 files changed, 153 insertions, 19 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)
diff --git a/src/match_up/__init__.py b/src/match_up/__init__.py
index 04c2f12..95f767e 100644
--- a/src/match_up/__init__.py
+++ b/src/match_up/__init__.py
@@ -1,33 +1,60 @@
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()
+# 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 run(self):
+# self._dashboard.run(debug=self._debug)
-def main():
- a = Application(debug=True)
- a.run()
+# def main():
+# a = Application(debug=True)
+# a.run()
+
+
+app = Flask("Match Up", template_folder="templates")
+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(
+ # files(base_template_path).joinpath("index.html").name,
+ # title="My Generated Page",
+ # people=session.data.get_players(),
+ # )
+ return render_template(
+ "index.html",
+ title="My Generated Page",
+ people=session.data.get_players(),
+ )
+
+
+if __name__ == "__main__":
+ print("Starting app")
+ app.run(host="localhost", debug=True, port=80)
diff --git a/src/match_up/templates/index.html b/src/match_up/templates/index.html
index 23bba20..e292734 100644
--- a/src/match_up/templates/index.html
+++ b/src/match_up/templates/index.html
@@ -1,10 +1,11 @@
<!doctype html>
+<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
- <h1>{{ title }}</h1>
+ <h1>Match Up!</h1>
<ul>
{% for person in people %}
<li>{{ person.first_name }}</li>
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..db4a991
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,51 @@
+<!doctype html>
+<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">
+
+<html>
+ <head>
+ <title>Match Up!</title>
+ </head>
+ <body>
+ <h1>Match Up!</h1>
+ <div class="row">
+ <div style=" float: left; width: 60%">
+ <table>
+ <thead>
+ <tr>
+ <th> Court </th>
+ <th> Team 1 </th>
+ <th> Team 2 </th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for game in game_list %}
+ <tr>
+ <td width="10%"> {{game.court_number}} </td>
+ <td width="40%"> {{game.team_1.player_1.get_name()}} <br> {{game.team_1.player_2.get_name()}} </td>
+ <td width="40%"> {{game.team_2.player_1.get_name()}} <br> {{game.team_2.player_2.get_name()}} </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ <div style=" float: left; width: 30%">
+ <table>
+ <thead>
+ <tr>
+ <th> Player </th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for player in player_list %}
+ <tr>
+ <td style={% if player.status %} "color : green" {% else %} "color : red" {% endif %}>
+ {{ player.get_name() }}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </body>
+</html> \ No newline at end of file