import os import re from functools import lru_cache from pydantic import BaseSettings from flask import Flask BASE_DIR = os.path.dirname(os.path.abspath(__file__)) APP_ENV = os.environ.get("APP_ENV", "development") class BaseConfig(BaseSettings): """Base configuration.""" ENV: str = "base" APP_NAME: str = "Open Law" SECRET_KEY: str SQLALCHEMY_TRACK_MODIFICATIONS: bool = False WTF_CSRF_ENABLED: bool = False # Super admin ADMIN_USERNAME: str ADMIN_PASSWORD: str # Pagination DEFAULT_PAGE_SIZE: int PAGE_LINKS_NUMBER: int MAX_SEARCH_RESULTS: int # HTTPProvider for SIWE HTTP_PROVIDER_URL: str # regex TAG_REGEX = re.compile(r"(#+[a-zA-Z0-9(_)]{1,})") # #tag USER_MENTION_REGEX = re.compile(r"(? DevelopmentConfig | TestingConfig | ProductionConfig: CONF_MAP = dict( development=DevelopmentConfig(), testing=TestingConfig(), production=ProductionConfig(), ) configuration = CONF_MAP[name] configuration.ENV = name return configuration