summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
authorKaran Jayachandra <karan.jayachandra@nxp.com>2024-10-11 18:56:48 +0200
committerKaran Jayachandra <karan.jayachandra@nxp.com>2024-10-11 18:56:48 +0200
commit20d668454a1e1d8f17f7e5d4d25f667f62381cd1 (patch)
tree5e13fc89296e4bb8e48c7296c51d4dd2122a4a63 /app.py
parent0db0ff2f1c712273ac48cb859c24253b1efa8384 (diff)
Working with Bulma CSS now
Diffstat (limited to 'app.py')
-rw-r--r--app.py28
1 files changed, 17 insertions, 11 deletions
diff --git a/app.py b/app.py
index 9f4caed..fac8a29 100644
--- a/app.py
+++ b/app.py
@@ -1,17 +1,16 @@
from os import getenv
-from model import CourtList, PlayerList, GameList
-from flask import Flask, abort, render_template, request
from dotenv import load_dotenv
+from flask import Flask, abort, render_template
+from model import CourtList, PlayerList, GameList
load_dotenv()
-print("Importing player list...\n")
-PLAYER_LIST = PlayerList(location="test_data.csv")
+PLAYER_LIST = PlayerList(location="test_data_large.csv")
COURT_LIST = CourtList(12)
-GAME_GENERATOR = GameList(COURT_LIST)
-print("List of player:\n")
-print(PLAYER_LIST)
+GAME_GENERATOR = GameList()
+GAME_GENERATOR.clear(COURT_LIST)
+
app = Flask("Match Up! Backend")
env_config = getenv("PROD_APP_SETTINGS", "config.DevelopmentConfig")
@@ -25,6 +24,7 @@ def home():
@app.route("/new-games", methods=["POST"])
def get_new_games():
+ print("Creating new games...")
GAME_GENERATOR.create_games(COURT_LIST, PLAYER_LIST)
return render_template(
"games.j2",
@@ -32,6 +32,16 @@ def get_new_games():
)
+@app.route("/clear-games", methods=["POST"])
+def clear_games():
+ print("Clearing games...")
+ GAME_GENERATOR.clear(COURT_LIST)
+ return render_template(
+ "games.j2",
+ games=GAME_GENERATOR.games,
+ )
+
+
@app.route("/game-list", methods=["GET"])
def get_list_of_games():
return render_template(
@@ -65,13 +75,9 @@ def get_list_of_players():
def toggle_court(court_number):
court_number = int(court_number)
selection = COURT_LIST.get_court(court_number)
- print(len(selection))
- print(selection)
if len(selection) != 1:
abort(404, f"Multiple courts requested: {len(selection)}")
- print(COURT_LIST.courts)
COURT_LIST.toggle_court(court_number)
- print(COURT_LIST.courts)
selection = COURT_LIST.get_court(court_number)
return render_template(
"court.j2",