from pydantic_settings import BaseSettings from typing import List class Settings(BaseSettings): MYSQL_HOST: str = "localhost" MYSQL_PORT: int = 3306 MYSQL_USER: str = "root" MYSQL_PASSWORD: str = "password" MYSQL_DATABASE: str = "huawei_market" API_PREFIX: str = "/api" API_TITLE: str = "鸿蒙应用展示平台API" API_VERSION: str = "1.0.0" DEBUG: bool = False CORS_ORIGINS: List[str] = ["http://localhost:5173", "http://localhost:3000"] @property def database_url(self) -> str: return f"mysql+aiomysql://{self.MYSQL_USER}:{self.MYSQL_PASSWORD}@{self.MYSQL_HOST}:{self.MYSQL_PORT}/{self.MYSQL_DATABASE}" class Config: env_file = ".env" settings = Settings()