数据库存储密码
Browse files
app.py
CHANGED
@@ -37,7 +37,8 @@ if os.environ.get("dockerrun") == "yes":
|
|
37 |
else:
|
38 |
dockerflag = False
|
39 |
|
40 |
-
authflag = False
|
|
|
41 |
|
42 |
if dockerflag:
|
43 |
my_api_key = os.environ.get("my_api_key")
|
@@ -49,12 +50,6 @@ if dockerflag:
|
|
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 (
|
@@ -454,21 +449,30 @@ logging.info(
|
|
454 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
455 |
demo.title = "中建chatgpt"
|
456 |
|
|
|
|
|
|
|
457 |
if __name__ == "__main__":
|
458 |
reload_javascript()
|
459 |
# if running in Docker
|
460 |
if dockerflag:
|
461 |
if authflag:
|
462 |
-
|
463 |
-
|
464 |
-
|
|
|
|
|
|
|
465 |
)
|
466 |
else:
|
467 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False, favicon_path="./assets/favicon.png")
|
468 |
# if not running in Docker
|
469 |
else:
|
470 |
if authflag:
|
471 |
-
|
|
|
|
|
|
|
472 |
else:
|
473 |
demo.queue(concurrency_count=1000).launch(share=False, favicon_path="./assets/favicon.ico", inbrowser=True) # 改为 share=True 可以创建公开分享链接
|
474 |
# demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
|
|
37 |
else:
|
38 |
dockerflag = False
|
39 |
|
40 |
+
# authflag = False
|
41 |
+
authflag = True
|
42 |
|
43 |
if dockerflag:
|
44 |
my_api_key = os.environ.get("my_api_key")
|
|
|
50 |
# password = os.environ.get("PASSWORD")
|
51 |
# if not (isinstance(username, type(None)) or isinstance(password, type(None))):
|
52 |
# authflag = True
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
else:
|
55 |
if (
|
|
|
449 |
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
450 |
demo.title = "中建chatgpt"
|
451 |
|
452 |
+
|
453 |
+
|
454 |
+
|
455 |
if __name__ == "__main__":
|
456 |
reload_javascript()
|
457 |
# if running in Docker
|
458 |
if dockerflag:
|
459 |
if authflag:
|
460 |
+
for user in users:
|
461 |
+
username=user["username"]
|
462 |
+
password=user["password"]
|
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")
|
469 |
# if not running in Docker
|
470 |
else:
|
471 |
if authflag:
|
472 |
+
for user in users:
|
473 |
+
username=user["username"]
|
474 |
+
password=user["password"]
|
475 |
+
demo.queue().launch(share=False, auth=(username, password), favicon_path="./assets/favicon.png", inbrowser=True)
|
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) # 可自定义端口
|
test.py
CHANGED
@@ -2,5 +2,5 @@ import os
|
|
2 |
os.path.exists("api_key.txt")
|
3 |
with open("api_key.txt", "r") as f:
|
4 |
my_api_key = f.read().strip()
|
5 |
-
|
6 |
print(my_api_key)
|
|
|
2 |
os.path.exists("api_key.txt")
|
3 |
with open("api_key.txt", "r") as f:
|
4 |
my_api_key = f.read().strip()
|
5 |
+
my_api_key = os.environ.get("my_api_key")
|
6 |
print(my_api_key)
|