From 88d7300021cd3963f2d6a6202609b0f6e956cdab Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Fri, 4 Oct 2024 18:23:33 +0200 Subject: Added the games view --- app.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index 7d9f808..7778b3e 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ from os import getenv -from model import PlayerList -from flask import Flask, abort, render_template +from model import PlayerList, GameList +from flask import Flask, abort, render_template, request from dotenv import load_dotenv load_dotenv() @@ -8,6 +8,7 @@ load_dotenv() print("Importing player list...\n") PLAYER_LIST = PlayerList(location="test_data.csv") +GAME_GENERATOR = GameList() print("List of player:\n") print(PLAYER_LIST) @@ -21,6 +22,34 @@ def home(): return render_template("index.j2") +# @app.route("/courts", methods=["POST"]) +# def set_courts(): +# print(request) +# print(request.data) +# print(request.json) +# print(request.args) +# return render_template( +# "courts.j2", +# courts=GAME_GENERATOR.courts, +# ) + + +@app.route("/new-games", methods=["POST"]) +def get_new_games(): + return render_template( + "games.j2", + games=GAME_GENERATOR.create_games(PLAYER_LIST.get_active_players()), + ) + + +@app.route("/game-list", methods=["GET"]) +def get_list_of_games(): + return render_template( + "games.j2", + games=GAME_GENERATOR.create_games(PLAYER_LIST.get_active_players()), + ) + + @app.route("/player-toggle/", methods=["POST"]) def toggle_player(player_request): selection = PLAYER_LIST.get_player(player_request) -- cgit v1.3.1