31 lines
722 B
Python
31 lines
722 B
Python
from functools import lru_cache
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
api_name: str = "fquiz-api"
|
|
api_version: str = "0.1.0"
|
|
api_host: str = "0.0.0.0"
|
|
api_port: int = 8000
|
|
api_cors_origins: str = "http://localhost:3000,http://127.0.0.1:3000"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=False,
|
|
)
|
|
|
|
@property
|
|
def cors_origins(self) -> list[str]:
|
|
return [
|
|
origin.strip()
|
|
for origin in self.api_cors_origins.split(",")
|
|
if origin.strip()
|
|
]
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
return Settings()
|