Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
853300a
1
Parent(s):
bd419af
支持在文件中设定默认key和用户名、密码,更新本项目更方便了
Browse files- ChuanhuChatbot.py +14 -1
ChuanhuChatbot.py
CHANGED
@@ -27,6 +27,16 @@ if dockerflag:
|
|
27 |
authflag = False
|
28 |
else:
|
29 |
authflag = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
title = """<h1 align="center">川虎ChatGPT 🚀</h1>"""
|
32 |
description = """<div align=center>
|
@@ -162,7 +172,10 @@ if dockerflag:
|
|
162 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False)
|
163 |
#if not running in Docker
|
164 |
else:
|
165 |
-
|
|
|
|
|
|
|
166 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
167 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
168 |
#demo.queue().launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
|
|
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>
|
|
|
172 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False)
|
173 |
#if not running in Docker
|
174 |
else:
|
175 |
+
if authflag:
|
176 |
+
demo.queue().launch(share=False, auth=(username, password))
|
177 |
+
else:
|
178 |
+
demo.queue().launch(share=False) # 改为 share=True 可以创建公开分享链接
|
179 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
180 |
#demo.queue().launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
181 |
#demo.queue().launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|