From 030e4853fac30a167b321e46913ca9113404bf62 Mon Sep 17 00:00:00 2001 From: Siddhanth Gupta Date: Wed, 4 Nov 2026 13:06:31 +0530 Subject: [PATCH] fix(fri): let startserver run without FLASK_SECRET_KEY set main.py refuses to start without FLASK_SECRET_KEY unless FLASK_ENV is development, and the launchers set neither, so startserver failed on a fresh checkout and pointed users at pip. Set a throwaway key for the run when none is set, fix the error hint and the README sentence, and make startserver executable. --- README.md | 2 +- startserver | 4 +++- startserver.bat | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) mode change 100644 => 100755 startserver diff --git a/README.md b/README.md index 1d59a862..a723b8cd 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,7 @@ Set a secure secret key for the Flask server before running in production: export FLASK_SECRET_KEY=$(python -c "import secrets; print(secrets.token_hex(32))") ``` -Do **NOT** commit your secret key to version control. If `FLASK_SECRET_KEY` is not set, a temporary random key will be generated automatically (suitable for local development only). +Do **NOT** commit your secret key to version control. If `FLASK_SECRET_KEY` is not set, `startserver` / `startserver.bat` generate a temporary random key for that run (suitable for local development only); when running `main.py` directly, set `FLASK_ENV=development` instead. For a detailed and more scientific documentation, please read our extensive [open-access research paper on CONTROL-CORE](https://doi.org/10.1109/ACCESS.2022.3161471). This paper has a complete discussion on the CONTROL-CORE architecture and deployment, together with the commands to execute the studies in different programming languages and programming environments (Ubuntu, Windows, MacOS, Docker, and distributed execution). diff --git a/startserver b/startserver old mode 100644 new mode 100755 index 73bd6de6..bb58446c --- a/startserver +++ b/startserver @@ -1,5 +1,7 @@ #!/bin/bash cd fri/server +# main.py refuses to start without a secret key; use a throwaway one for local runs +export FLASK_SECRET_KEY="${FLASK_SECRET_KEY:-$(head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n')}" if ! command -v python3 >/dev/null 2>&1; then python main.py else @@ -8,7 +10,7 @@ fi if [ $? -ne 0 ]; then echo "" - echo "Error: Make sure modules are installed from fri/requirements.txt" + echo "Error: the server exited with an error (see above). If a module is missing:" echo "Run: pip install -r fri/requirements.txt" echo "" fi diff --git a/startserver.bat b/startserver.bat index 856824a4..ad2fff02 100644 --- a/startserver.bat +++ b/startserver.bat @@ -1,8 +1,10 @@ cd fri\server +rem main.py refuses to start without a secret key; use a throwaway one for local runs +if not defined FLASK_SECRET_KEY for /f %%k in ('python -c "import secrets; print(secrets.token_hex(32))"') do @set "FLASK_SECRET_KEY=%%k" python main.py if errorlevel 1 ( echo. - echo Error: Make sure modules are installed from fri/requirements.txt + echo Error: the server exited with an error ^(see above^). If a module is missing: echo Run: pip install -r fri/requirements.txt echo. ) \ No newline at end of file