From f6f8cb4f1bf643a8d29f917d5c977cb2343f2672 Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Wed, 16 Oct 2024 11:46:39 +0200 Subject: Clean folder and configuration --- app.py | 7 ++----- config.py | 9 ++------- gen_test_data.py | 2 +- model.py | 4 ++-- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/app.py b/app.py index a81bde0..40b75a1 100644 --- a/app.py +++ b/app.py @@ -4,13 +4,10 @@ from controller import RoundGenerator from model import CourtList, PlayerList from flask import Flask, render_template, request - load_dotenv() - - app = Flask("Match Up! Backend") -app.config.from_object(getenv("PROD_APP_SETTINGS", "config.DevelopmentConfig")) -rg = RoundGenerator(courts=CourtList(12), players=PlayerList("test_data_large.csv")) +app.config.from_object(getenv("PROD_APP_SETTINGS")) +rg = RoundGenerator(courts=CourtList(12), players=PlayerList(getenv("DATABASE"))) @app.route("/", methods=["GET"]) diff --git a/config.py b/config.py index bff125a..7d01933 100644 --- a/config.py +++ b/config.py @@ -5,12 +5,8 @@ class Config: ASSETS_DEBUG = False -class YouthConfig(Config): - DATABASE = "test_data_large.csv" - - -class SeniorConfig(Config): - DATABASE = "test_data_large.csv" +class ProductionConfig(Config): + pass class DevelopmentConfig(Config): @@ -18,4 +14,3 @@ class DevelopmentConfig(Config): DEVELOPMENT = True TEMPLATES_AUTO_RELOAD = True ASSETS_DEBUG = True - DATABASE = "test_data_large.csv" diff --git a/gen_test_data.py b/gen_test_data.py index bf11653..a49594f 100644 --- a/gen_test_data.py +++ b/gen_test_data.py @@ -1,7 +1,7 @@ from csv import writer from random import randint from names import get_full_name -from ..model import Player, MIN_LEVEL, MAX_LEVEL +from model import Player, MIN_LEVEL, MAX_LEVEL PLAYER_COUNT = 80 diff --git a/model.py b/model.py index 3e76085..ba5cb9b 100644 --- a/model.py +++ b/model.py @@ -55,10 +55,10 @@ class CourtList: @dataclass class PlayerList: - location: Path + location: str def __post_init__(self) -> None: - with open(self.location, newline="") as file: + with open("data/" + self.location, newline="") as file: pointer = reader(file) next(pointer, None) players = { -- cgit v1.3.1