summaryrefslogtreecommitdiff
path: root/src/match_up/__init__.py
blob: 04c2f128e6503eb11f6f34c3e83d5442df374691 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from dash import Dash
from pathlib import PurePath
from match_up.model import PlaySession
from match_up.view import MainLayout
from match_up.tests import (
    TEST_DATABASE_LOCATION,
)
from dash_bootstrap_components.themes import ZEPHYR

DATABASE_LOCATION = "storage.json"


class Application:
    def __init__(self, debug=False):
        self._debug = debug
        if debug:
            database_location = TEST_DATABASE_LOCATION
        else:
            database_location = DATABASE_LOCATION
        self._session = PlaySession(PurePath(database_location))
        self._dashboard = Dash("Match Up!", external_stylesheets=[ZEPHYR])
        self._layout = MainLayout(
            self._session.data.get_players(), self._session.get_matches()
        )
        self._dashboard.layout = self._layout.get()

    def run(self):
        self._dashboard.run(debug=self._debug)


def main():
    a = Application(debug=True)
    a.run()