lavkach3
52 строки · 1.3 Кб
1import logging2import os3
4from dotenv import load_dotenv5from pydantic import BaseConfig6
7from core.service_config import Config as CoreConfig8
9BaseConfig.arbitrary_types_allowed = True10logging.basicConfig(level=logging.INFO)11
12load_dotenv()13
14
15class Config(CoreConfig):16BROKER_PATH: str = 'app.prescription.prescription_server:app'17APP_HOST: str = os.environ.get("PRESCRIPTION_HOST") or os.environ.get("APP_HOST") or '127.0.0.1'18APP_PORT: int = os.environ.get("PRESCRIPTION_PORT") or os.environ.get("APP_PORT") or '8004'19APP_PROTOCOL: str = os.environ.get('PRESCRIPTION_PROTOCOL') or os.environ.get('APP_PROTOCOL') or 'http'20
21
22class DevelopmentConfig(Config):23...24
25class DockerConfig(Config):26APP_HOST: str = 'prescription_app'27APP_PORT: int = '80'28
29class LocalConfig(Config):30...31
32
33class ProductionConfig(Config):34...35
36
37def get_config():38env = os.getenv("ENV", "local")39for name, value in os.environ.items():40# logging.info("{0}: {1}".format(name, value))41# print("{0}: {1}".format(name, value))42pass43config_type = {44"dev": DevelopmentConfig(),45"local": LocalConfig(),46"docker": DockerConfig(),47"prod": ProductionConfig(),48}49return config_type[env]50
51
52config: Config = get_config()53