integrate static assets into webui command

This commit is contained in:
Jörg Thalheim
2023-08-25 17:08:39 +02:00
parent 79b02dffab
commit 9ae14a4f7d
11 changed files with 149 additions and 28 deletions

View File

@@ -0,0 +1,38 @@
# config.py
import logging
import os
from enum import Enum
from pydantic import BaseSettings
logger = logging.getLogger(__name__)
class EnvType(Enum):
production = "production"
development = "development"
@staticmethod
def from_environment() -> "EnvType":
t = os.environ.get("CLAN_WEBUI_ENV", "production")
try:
return EnvType[t]
except KeyError:
logger.warning(f"Invalid environment type: {t}, fallback to production")
return EnvType.production
def is_production(self) -> bool:
return self == EnvType.production
def is_development(self) -> bool:
return self == EnvType.development
class Settings(BaseSettings):
env: EnvType = EnvType.from_environment()
dev_port: int = int(os.environ.get("CLAN_WEBUI_DEV_PORT", 3000))
dev_host: str = os.environ.get("CLAN_WEBUI_DEV_HOST", "localhost")
# global instance
settings = Settings()