Liuli commited on
Commit
6fe2a5d
1 Parent(s): 6582408
Files changed (1) hide show
  1. app.py +32 -11
app.py CHANGED
@@ -10,6 +10,20 @@ from presets import *
10
  from overwrites import *
11
  from chat_func import *
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  logging.basicConfig(
14
  level=logging.DEBUG,
15
  format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
@@ -31,10 +45,17 @@ if dockerflag:
31
  logging.error("Please give a api key!")
32
  sys.exit(1)
33
  # auth
34
- username = os.environ.get("USERNAME")
35
- password = os.environ.get("PASSWORD")
36
- if not (isinstance(username, type(None)) or isinstance(password, type(None))):
37
- authflag = True
 
 
 
 
 
 
 
38
  else:
39
  if (
40
  not my_api_key
@@ -43,13 +64,13 @@ else:
43
  ):
44
  with open("api_key.txt", "r") as f:
45
  my_api_key = f.read().strip()
46
- if os.path.exists("auth.json"):
47
- with open("auth.json", "r") as f:
48
- auth = json.load(f)
49
- username = auth["username"]
50
- password = auth["password"]
51
- if username != "" and password != "":
52
- authflag = True
53
 
54
  gr.Chatbot.postprocess = postprocess
55
  PromptHelper.compact_text_chunks = compact_text_chunks
 
10
  from overwrites import *
11
  from chat_func import *
12
 
13
+ import requests
14
+ from urllib import parse
15
+
16
+ requestUrl = 'http://82.156.209.58:8520/api/user'
17
+ headers = {
18
+ 'Content-Type': 'application/x-www-form-urlencoded'
19
+ }
20
+ formData = {
21
+
22
+ }
23
+ data = parse.urlencode(formData, True)
24
+ response = requests.post(requestUrl, headers = headers, data = data)
25
+ users=response.json()["data"]
26
+
27
  logging.basicConfig(
28
  level=logging.DEBUG,
29
  format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
 
45
  logging.error("Please give a api key!")
46
  sys.exit(1)
47
  # auth
48
+ # username = os.environ.get("USERNAME")
49
+ # password = os.environ.get("PASSWORD")
50
+ # if not (isinstance(username, type(None)) or isinstance(password, type(None))):
51
+ # authflag = True
52
+ for user in users:
53
+ username=user["username"]
54
+ password=user["password"]
55
+ if not (isinstance(username, type(None)) or isinstance(password, type(None))):
56
+ authflag = True
57
+
58
+
59
  else:
60
  if (
61
  not my_api_key
 
64
  ):
65
  with open("api_key.txt", "r") as f:
66
  my_api_key = f.read().strip()
67
+ # if os.path.exists("auth.json"):
68
+ # with open("auth.json", "r") as f:
69
+ # auth = json.load(f)
70
+ # username = auth["username"]
71
+ # password = auth["password"]
72
+ # if username != "" and password != "":
73
+ # authflag = True
74
 
75
  gr.Chatbot.postprocess = postprocess
76
  PromptHelper.compact_text_chunks = compact_text_chunks