From 35dcc88bf011b64b55a3169fae12829bbfc9daa7 Mon Sep 17 00:00:00 2001 From: cheng zhen Date: Fri, 10 Jan 2025 21:41:57 +0800 Subject: [PATCH] feat: add check for .env file existence in config.py to ensure proper loading --- config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config.py b/config.py index f1201f0..f219b54 100644 --- a/config.py +++ b/config.py @@ -16,6 +16,9 @@ class Config: # 指定 .env 文件的路径 dotenv_path = os.path.join(application_path, ".env") + if not os.path.exists(dotenv_path): + raise FileNotFoundError(f"文件 {dotenv_path} 不存在") + # 加载 .env 文件 load_dotenv(dotenv_path)