ayuangpt commited on
Commit
82ef4f8
·
1 Parent(s): 878920f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -25,10 +25,10 @@ else:
25
  dockerflag = False
26
 
27
  authflag = False
 
28
 
29
- if not my_api_key:
30
- my_api_key = os.environ.get("my_api_key")
31
  if dockerflag:
 
32
  if my_api_key == "empty":
33
  logging.error("Please give a api key!")
34
  sys.exit(1)
@@ -36,6 +36,7 @@ if dockerflag:
36
  username = os.environ.get("USERNAME")
37
  password = os.environ.get("PASSWORD")
38
  if not (isinstance(username, type(None)) or isinstance(password, type(None))):
 
39
  authflag = True
40
  else:
41
  if (
@@ -46,12 +47,15 @@ else:
46
  with open("api_key.txt", "r") as f:
47
  my_api_key = f.read().strip()
48
  if os.path.exists("auth.json"):
 
49
  with open("auth.json", "r", encoding='utf-8') as f:
50
  auth = json.load(f)
51
- username = auth["username"]
52
- password = auth["password"]
53
- if username != "" and password != "":
54
- authflag = True
 
 
55
 
56
  gr.Chatbot.postprocess = postprocess
57
  PromptHelper.compact_text_chunks = compact_text_chunks
@@ -434,7 +438,7 @@ if __name__ == "__main__":
434
  if authflag:
435
  demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
436
  share=False,
437
- auth=(username, password),
438
  favicon_path="./assets/favicon.ico",
439
  inbrowser=True,
440
  )
 
25
  dockerflag = False
26
 
27
  authflag = False
28
+ auth_list = []
29
 
 
 
30
  if dockerflag:
31
+ my_api_key = os.environ.get("my_api_key")
32
  if my_api_key == "empty":
33
  logging.error("Please give a api key!")
34
  sys.exit(1)
 
36
  username = os.environ.get("USERNAME")
37
  password = os.environ.get("PASSWORD")
38
  if not (isinstance(username, type(None)) or isinstance(password, type(None))):
39
+ auth_list.append((os.environ.get("USERNAME"), os.environ.get("PASSWORD")))
40
  authflag = True
41
  else:
42
  if (
 
47
  with open("api_key.txt", "r") as f:
48
  my_api_key = f.read().strip()
49
  if os.path.exists("auth.json"):
50
+ authflag = True
51
  with open("auth.json", "r", encoding='utf-8') as f:
52
  auth = json.load(f)
53
+ for _ in auth:
54
+ if auth[_]["username"] and auth[_]["password"]:
55
+ auth_list.append((auth[_]["username"], auth[_]["password"]))
56
+ else:
57
+ logging.error("请检查auth.json文件中的用户名和密码!")
58
+ sys.exit(1)
59
 
60
  gr.Chatbot.postprocess = postprocess
61
  PromptHelper.compact_text_chunks = compact_text_chunks
 
438
  if authflag:
439
  demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
440
  share=False,
441
+ auth=auth_list,
442
  favicon_path="./assets/favicon.ico",
443
  inbrowser=True,
444
  )