aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui/_app.py
blob: f54f72e8d6f683bcb0a18deffcc1d64b7a8689a2 (about) (plain)
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
# SPDX-License-Identifier: CC0-1.0

# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
#
# Available under the terms of Creative Commons Zero v1.0 Universal.

import enum
import dataclasses as dc
import typing as t

import flask

from .. import state as st


class UIDomain(enum.Enum):
    MAIN         = enum.auto()
    LANDING_PAGE = enum.auto()

@dc.dataclass(init=False)
class WebUIApp(flask.Flask):
    _haketilo_state:     st.HaketiloState
    _haketilo_ui_domain: t.ClassVar[UIDomain]

def get_haketilo_state() -> st.HaketiloState:
    return t.cast(WebUIApp, flask.current_app)._haketilo_state

def get_haketilo_ui_domain() -> UIDomain:
    return t.cast(WebUIApp, flask.current_app)._haketilo_ui_domain