19 lines
501 B
Python
19 lines
501 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
from .settings import Settings
|
|
|
|
_env = os.getenv("ENV", "dev")
|
|
_env_files = {"dev": ".env", "test": ".env.test", "prod": ".env.prod"}
|
|
|
|
# 定位项目根目录(config 上两级)
|
|
_project_root = Path(__file__).resolve().parent.parent.parent
|
|
_env_file = _project_root / _env_files.get(_env, ".env")
|
|
|
|
if not _env_file.exists():
|
|
raise FileNotFoundError(f".env 文件不存在: {_env_file}")
|
|
|
|
settings = Settings(_env_file=str(_env_file))
|
|
|
|
__all__ = ["settings"]
|