From d18e5880b47fcdf6542bcb9502e8cf35a4276f05 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Mon, 14 Oct 2024 11:10:35 +0200 Subject: Cleand up the application code a bit --- app.py | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index c4e4d89..6c1609a 100644 --- a/app.py +++ b/app.py @@ -26,38 +26,26 @@ def home(): def get_random_games(): print("Creating new games...") GAME_GENERATOR.create_random_games(COURT_LIST, PLAYER_LIST) - return render_template( - "games.j2", - games=GAME_GENERATOR.games, - ) + return render_template("games.j2", games=GAME_GENERATOR.games) @app.route("/skilled-games", methods=["POST"]) def get_skilled_games(): print("Creating new games...") GAME_GENERATOR.create_skilled_games(COURT_LIST, PLAYER_LIST) - return render_template( - "games.j2", - games=GAME_GENERATOR.games, - ) + return render_template("games.j2", games=GAME_GENERATOR.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, - ) + return render_template("games.j2", games=GAME_GENERATOR.games) @app.route("/game-list", methods=["GET"]) def get_list_of_games(): - return render_template( - "games.j2", - games=GAME_GENERATOR.games, - ) + return render_template("games.j2", games=GAME_GENERATOR.games) @app.route("/player-toggle/", methods=["POST"]) @@ -67,18 +55,12 @@ def toggle_player(player_request): abort(404) PLAYER_LIST.toggle_player(player_request) selection = PLAYER_LIST.get_player(player_request) - return render_template( - "player.j2", - player=selection[0], - ) + return render_template("player.j2", player=selection[0]) @app.route("/player-list", methods=["GET"]) def get_list_of_players(): - return render_template( - "players.j2", - players=PLAYER_LIST.players, - ) + return render_template("players.j2", players=PLAYER_LIST.players) @app.route("/court-toggle/", methods=["POST"]) @@ -89,15 +71,9 @@ def toggle_court(court_number): abort(404, f"Multiple courts requested: {len(selection)}") COURT_LIST.toggle_court(court_number) selection = COURT_LIST.get_court(court_number) - return render_template( - "court.j2", - court=selection[0], - ) + return render_template("court.j2", court=selection[0]) @app.route("/court-list", methods=["GET"]) def get_list_of_courts(): - return render_template( - "courts.j2", - courts=COURT_LIST.courts, - ) + return render_template("courts.j2", courts=COURT_LIST.courts) -- cgit v1.3.1