Tuchuanhuhuhu commited on
Commit
ba6667e
·
1 Parent(s): 9f02a13

改进文件方式设置密钥的逻辑

Browse files
Files changed (1) hide show
  1. ChuanhuChatbot.py +6 -5
ChuanhuChatbot.py CHANGED
@@ -15,6 +15,8 @@ if os.environ.get('dockerrun') == 'yes':
15
  else:
16
  dockerflag = False
17
 
 
 
18
  if dockerflag:
19
  my_api_key = os.environ.get('my_api_key')
20
  if my_api_key == "empty":
@@ -23,20 +25,19 @@ if dockerflag:
23
  #auth
24
  username = os.environ.get('USERNAME')
25
  password = os.environ.get('PASSWORD')
26
- if isinstance(username, type(None)) or isinstance(password, type(None)):
27
- authflag = False
28
- else:
29
  authflag = True
30
  else:
31
  if os.path.exists("api_key.txt"):
32
  with open("api_key.txt", "r") as f:
33
- my_api_key = f.read()
34
  if os.path.exists("auth.json"):
35
  with open("auth.json", "r") as f:
36
  auth = json.load(f)
37
  username = auth["username"]
38
  password = auth["password"]
39
- authflag = True
 
40
 
41
  title = """<h1 align="center">川虎ChatGPT 🚀</h1>"""
42
  description = """<div align=center>
 
15
  else:
16
  dockerflag = False
17
 
18
+ authflag = False
19
+
20
  if dockerflag:
21
  my_api_key = os.environ.get('my_api_key')
22
  if my_api_key == "empty":
 
25
  #auth
26
  username = os.environ.get('USERNAME')
27
  password = os.environ.get('PASSWORD')
28
+ if not (isinstance(username, type(None)) or isinstance(password, type(None))):
 
 
29
  authflag = True
30
  else:
31
  if os.path.exists("api_key.txt"):
32
  with open("api_key.txt", "r") as f:
33
+ my_api_key = f.read().strip()
34
  if os.path.exists("auth.json"):
35
  with open("auth.json", "r") as f:
36
  auth = json.load(f)
37
  username = auth["username"]
38
  password = auth["password"]
39
+ if username != "" and password != "":
40
+ authflag = True
41
 
42
  title = """<h1 align="center">川虎ChatGPT 🚀</h1>"""
43
  description = """<div align=center>