From 20d668454a1e1d8f17f7e5d4d25f667f62381cd1 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 11 Oct 2024 18:56:48 +0200 Subject: Working with Bulma CSS now --- app.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'app.py') 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", -- cgit v1.3.1