Skip to content

Commit d7c9cab

Browse files
committed
The private-mode setting is now applied without the need to restart the server
1 parent 8f01ee9 commit d7c9cab

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/FreeGPT4_Server.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def load_settings(file=SETTINGS_FILE):
222222
data["token"] = token
223223
elif (data["token"] != ""):
224224
token = data["token"]
225+
args.private_mode = True
225226

226227
if (args.remove_sources == False):
227228
args.remove_sources = data["remove_sources"]
@@ -299,10 +300,12 @@ def save_settings(request, file):
299300
c.execute("UPDATE settings SET password = ?", (generate_password_hash(request.form["new_password"]),))
300301

301302
file = request.files["cookie_file"]
302-
if (args.private_mode or bool(request.form["private_mode"] == "true")):
303+
if (bool(request.form["private_mode"] == "true")):
303304
c.execute("UPDATE settings SET token = ?", (request.form["token"],))
305+
args.private_mode = True
304306
else:
305-
c.execute("UPDATE settings SET token = ?", ("",))
307+
c.execute("UPDATE settings SET token = ''")
308+
args.private_mode = False
306309
#checks if the file is not empty
307310
if file.filename != '':
308311
#checks if the file is a json file
@@ -377,6 +380,7 @@ async def index() -> str:
377380
print("start")
378381
if request.method == "GET":
379382
question = request.args.get(args.keyword) #text
383+
print(args.private_mode)
380384
if (args.private_mode and request.args.get("token") != data["token"]):
381385
return "<p id='response'>Invalid token</p>"
382386
print("get")

0 commit comments

Comments
 (0)