carcost/api/config.py
2026-04-10 23:24:51 +08:00

20 lines
483 B
Python

# config.py
from pydantic_settings import BaseSettings
import os
from dotenv import load_dotenv
# 加载环境变量
load_dotenv()
class Settings(BaseSettings):
DATABASE_URL: str = os.getenv("DATABASE_URL", "postgresql://postgres:password@localhost:5432/carcost")
TITLE: str = os.getenv("TITLE", "CarCost")
VERSION: str = os.getenv("VERSION", "1.0.0")
DEBUG: bool = os.getenv("DEBUG", "false").lower() == "true"
# 创建全局配置实例
settings = Settings()