diff options
Diffstat (limited to 'app.py')
| -rw-r--r-- | app.py | 28 |
1 files changed, 17 insertions, 11 deletions
@@ -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", |
