diff --git a/README.md b/README.md index 1d59a86..a723b8c 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 73bd6de..bb58446 --- 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 856824a..ad2fff0 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