Q: How to properly store a global variable in flask application I am currently writing a flask based frontend for a university project.
One of the settings an admin can change is to set a value between -1 and 12 to set the currently active repo the students can upload to.
I want the admin to be able to set this setting and then keep it persistent between server restarts. My first thought was to use the flask app config to save it as a key value. However this is not consistent between server restarts. So my next thought is to save this in a seperate configuration file or alternatively in a database, though the latter seems to be overkill for this single setting.
Is there a better way to handle this beyond a seperate configuration file that contains this value and gets imported on startup?

A: You can add the repo to UPLOAD FOLDER in app.config. Add these lines to your flaskapp (at the beginning):
UPLOAD_FOLDER = 'your_path'
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'jfif'])
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

And inside route that handles the file, add this:
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

Alternatively, you can create a txt file (let's name it 'repo.txt') and write the repo in it. Then load it in your flask (either as global variable or in specific routes, the second is recommended) with:
with open('repo.txt', 'r') as f:
    myrepo=f.read()

This way you will just have to update the txt file instead of the app itself
