Skip to content
Snippets Groups Projects
Commit a662ceb2 authored by Julian's avatar Julian
Browse files

Fix SECRET_KEY auto-generation in debug mode

Compatibility fix for Flask v2 (Debian Bookworm) and newer
parent 16f5ae99
No related branches found
No related tags found
No related merge requests found
......@@ -46,9 +46,10 @@ def init_config(app: Flask, test_config):
if load_config_file(app, os.path.join(app.instance_path, filename), silent=True):
break
if app.env == "production" and app.secret_key is None:
raise Exception("SECRET_KEY not configured and we are running in production mode!")
app.config.setdefault("SECRET_KEY", secrets.token_hex(128))
if app.secret_key is None:
if app.env == "production":
raise Exception("SECRET_KEY not configured and we are running in production mode!")
app.secret_key = secrets.token_hex(128)
def create_app(test_config=None): # pylint: disable=too-many-locals,too-many-statements
app = Flask(__name__, instance_relative_config=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment