Initial Commit
This commit is contained in:
46
api/app/settings.py
Normal file
46
api/app/settings.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import json
|
||||
from functools import lru_cache
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
ENVIRONMENT: str = "dev"
|
||||
|
||||
SWAGGER_HOST: str = "localhost:5000"
|
||||
|
||||
API_PREFIX_STRING: str = "/api"
|
||||
API_DESCRIPTION: str = "vtb_dashboard_api"
|
||||
|
||||
DASHBOARD_LOG: str = "vtb_dashboard_api.log"
|
||||
|
||||
POSTGRES_SERVER: str = "localhost"
|
||||
POSTGRES_PORT: int = 5432
|
||||
POSTGRES_USER: str
|
||||
POSTGRES_PASSWORD: str
|
||||
POSTGRES_DB: str = "virt.dashboard"
|
||||
|
||||
DEBUG: bool = False
|
||||
|
||||
@property
|
||||
def SQLALCHEMY_DATABASE_URI(self):
|
||||
return f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_SERVER}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}" # noqa
|
||||
|
||||
@property
|
||||
def CUSTOM_SWAGGER(self):
|
||||
with open("custom_swagger.json") as j_fp:
|
||||
custom_swagger = json.load(j_fp)
|
||||
custom_swagger["host"] = self.SWAGGER_HOST
|
||||
return custom_swagger
|
||||
|
||||
model_config = SettingsConfigDict(extra='allow', env_file=".env")
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_config():
|
||||
load_dotenv()
|
||||
return Settings()
|
||||
|
||||
|
||||
config = get_config()
|
||||
Reference in New Issue
Block a user