liuyuqi-dellpc 1 month ago
parent
commit
648402b854
3 changed files with 6 additions and 2 deletions
  1. 3 0
      .gitignore
  2. 1 1
      client.py
  3. 2 1
      fgh/config.py

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+*.pyc
+
+.env

+ 1 - 1
client.py

@@ -32,7 +32,7 @@ fgh curl -O https://ghproxy.org/https://raw.githubusercontent.com/microsoft/vsco
 
     def read_config(self):
         import dotenv
-        current_dir = os.getcwd()
+        current_dir = os.path.dirname(os.path.realpath(__file__))
         dotenv.load_dotenv(os.path.join(current_dir, '.env'))
         fgit_host = os.getenv('FGH_HOST')
         try:

+ 2 - 1
fgh/config.py

@@ -11,7 +11,8 @@ import os
 from dotenv import load_dotenv
 
 if os.path.exists('.env'):
-    load_dotenv('.env', verbose=True)
+    app_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+    load_dotenv(os.path.join(app_path, '.env'), verbose=True)
 
 class BaseConfig:
     ''' 基础配置 '''