The app and static files are served from a single domain, we don't use cross domain requests at all so removing it locks it down to the most restrictive state, which seems reasonable. It was initially added from an example without true understanding of the need.
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# contains all the settings the app uses at runtime, these are transformed
|
|
# versions of the config file and flags values
|
|
import os
|
|
import mft
|
|
import mft.config
|
|
from pathlib import Path
|
|
|
|
|
|
class Settings:
|
|
def __init__(self, config_path):
|
|
self.set_constants()
|
|
self.config_path = config_path
|
|
if not config_path.exists():
|
|
raise RuntimeError("Configuration file does not exist")
|
|
config = mft.config.load_config(self.config_path)
|
|
self.set_config_file_values(config)
|
|
|
|
def set_constants(self):
|
|
self.app_name: str = "MinimalFinanceTracker"
|
|
self.version: str = mft.__version__
|
|
self.api_prefix: str = "/api"
|
|
|
|
def set_config_file_values(self, config):
|
|
self.database_path: Path = Path(config.mft.database).expanduser().absolute()
|
|
self.host = config.server.host
|
|
self.port = config.server.port
|
|
|
|
|
|
# NOTE: This variable is set by the parent cli process. See
|
|
# mft.cli:delayed_settings_import for more information and justification
|
|
config_path = Path(os.environ["MFT_CONFIG_PATH"])
|
|
if not config_path.exists():
|
|
raise RuntimeError("Config file does not exist")
|
|
settings = Settings(config_path)
|