bd7635986a
Vue 前端 + FastAPI 后端,含部署脚本与词典数据。 Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
848 B
Python
34 lines
848 B
Python
from functools import lru_cache
|
|
from urllib.parse import quote_plus
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
extra="ignore",
|
|
)
|
|
|
|
mysql_host: str = "localhost"
|
|
mysql_port: int = 3306
|
|
mysql_user: str = "boot"
|
|
mysql_password: str = "888888"
|
|
mysql_database: str = "wordloop"
|
|
|
|
@property
|
|
def database_url(self) -> str:
|
|
user = quote_plus(self.mysql_user)
|
|
password = quote_plus(self.mysql_password)
|
|
return (
|
|
f"mysql+pymysql://{user}:{password}"
|
|
f"@{self.mysql_host}:{self.mysql_port}/{self.mysql_database}"
|
|
"?charset=utf8mb4"
|
|
)
|
|
|
|
|
|
@lru_cache
|
|
def get_settings() -> Settings:
|
|
return Settings()
|