test
Browse files
app.py
CHANGED
@@ -10,19 +10,15 @@ from presets import *
|
|
10 |
from overwrites import *
|
11 |
from chat_func import *
|
12 |
|
13 |
-
import
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
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,
|
@@ -449,6 +445,12 @@ logging.info(
|
|
449 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
450 |
demo.title = "中建chatgpt"
|
451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
|
453 |
|
454 |
|
@@ -457,12 +459,9 @@ if __name__ == "__main__":
|
|
457 |
# if running in Docker
|
458 |
if dockerflag:
|
459 |
if authflag:
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
demo.queue().launch(
|
464 |
-
server_name="0.0.0.0", server_port=7860, auth=(username, password),
|
465 |
-
favicon_path="./assets/favicon.png"
|
466 |
)
|
467 |
else:
|
468 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False, favicon_path="./assets/favicon.png")
|
@@ -470,9 +469,9 @@ if __name__ == "__main__":
|
|
470 |
else:
|
471 |
if authflag:
|
472 |
for user in users:
|
473 |
-
username=user[
|
474 |
-
password=user[
|
475 |
-
demo.queue().launch(share=False, auth=
|
476 |
else:
|
477 |
demo.queue(concurrency_count=1000).launch(share=False, favicon_path="./assets/favicon.ico", inbrowser=True) # 改为 share=True 可以创建公开分享链接
|
478 |
# demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
|
|
10 |
from overwrites import *
|
11 |
from chat_func import *
|
12 |
|
13 |
+
import sqlite3
|
14 |
+
mydb=sqlite3.connect("user.db")
|
15 |
+
## 读取sqlite3的数据
|
16 |
+
cursor=mydb.cursor()
|
17 |
+
|
18 |
+
#查询表名
|
19 |
+
cursor.execute("SELECT username,password FROM user WHERE expire_time > date('now');")
|
20 |
+
users=cursor.fetchall()
|
21 |
+
|
|
|
|
|
|
|
|
|
22 |
|
23 |
logging.basicConfig(
|
24 |
level=logging.DEBUG,
|
|
|
445 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
446 |
demo.title = "中建chatgpt"
|
447 |
|
448 |
+
def authenticate(username, password):
|
449 |
+
# 验证用户名和密码是否匹配
|
450 |
+
for user in users:
|
451 |
+
if user[0] == username and user[1] == password:
|
452 |
+
return True
|
453 |
+
return False
|
454 |
|
455 |
|
456 |
|
|
|
459 |
# if running in Docker
|
460 |
if dockerflag:
|
461 |
if authflag:
|
462 |
+
demo.queue().launch(
|
463 |
+
server_name="0.0.0.0", server_port=7860, auth=authenticate,
|
464 |
+
favicon_path="./assets/favicon.png"
|
|
|
|
|
|
|
465 |
)
|
466 |
else:
|
467 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False, favicon_path="./assets/favicon.png")
|
|
|
469 |
else:
|
470 |
if authflag:
|
471 |
for user in users:
|
472 |
+
username=user[0]
|
473 |
+
password=user[1]
|
474 |
+
demo.queue().launch(share=False, auth=authenticate, favicon_path="./assets/favicon.png", inbrowser=True)
|
475 |
else:
|
476 |
demo.queue(concurrency_count=1000).launch(share=False, favicon_path="./assets/favicon.ico", inbrowser=True) # 改为 share=True 可以创建公开分享链接
|
477 |
# demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
requirements.txt
CHANGED
@@ -10,3 +10,4 @@ Pygments
|
|
10 |
llama_index
|
11 |
langchain
|
12 |
markdown
|
|
|
|
10 |
llama_index
|
11 |
langchain
|
12 |
markdown
|
13 |
+
requests
|
test.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
1 |
+
import sqlite3
|
2 |
+
mydb=sqlite3.connect("user.db")
|
3 |
+
## 读取sqlite3的数据
|
4 |
+
cursor=mydb.cursor()
|
5 |
+
|
6 |
+
#查询表名
|
7 |
+
cursor.execute("SELECT username,password FROM user WHERE expire_time > date('now');")
|
8 |
+
Tables=cursor.fetchall()
|
9 |
+
print(Tables)
|
user.db
ADDED
Binary file (8.19 kB). View file
|
|