From 7f5538d0c429a14f84d704976c7a59e3925c6780 Mon Sep 17 00:00:00 2001 From: Jonathan Wu Date: Fri, 19 Jan 2024 21:16:15 -0500 Subject: [PATCH] Remove really bad hacky code --- INSTALL.sh | 1 + src/default_settings.py | 14 +++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/INSTALL.sh b/INSTALL.sh index d8d1759..c856488 100755 --- a/INSTALL.sh +++ b/INSTALL.sh @@ -74,6 +74,7 @@ EOF mkdir -p "$DATA_DIR/logs" "$DATA_DIR/dl" "$DATA_DIR/backups" "$DATA_DIR/metadata/contests" mkdir -p "$DATA_DIR/metadata/problems" "$DATA_DIR/metadata/announcements" echo "Finishing setup..." +python -c "import secrets; print(secrets.token_hex(48))" > secret_key.txt # 384 bits ln -s "$DATA_DIR/logs" logs ln -s "$DATA_DIR/dl" dl ln -s "$DATA_DIR/metadata" metadata diff --git a/src/default_settings.py b/src/default_settings.py index c04b501..0b68610 100644 --- a/src/default_settings.py +++ b/src/default_settings.py @@ -2,18 +2,10 @@ import secrets import sys -# DO NOT MODIFY THESE SETTINGS! Scroll down to line 27 for settings that you should change +# DO NOT MODIFY THESE SETTINGS! Scroll down to line 19 for settings that you should change # The secret key is located in secret_key.txt by default -try: - with open("secret_key.txt", "r") as file: - secret_key = file.readline().strip() - SECRET_KEY = secret_key -except Exception as e: - sys.stderr.write(str(e)) - with open("secret_key.txt", "w") as file: - SECRET_KEY = secrets.token_hex(48) # 384 bits - file.write(SECRET_KEY) - +with open("secret_key.txt", "r") as file: + SECRET_KEY = file.readline().strip() TEMPLATES_AUTO_RELOAD = True SESSION_PERMANENT = True PERMANENT_SESSION_LIFETIME = 30 * 24 * 60 * 60 # 30d