Forums

where should i create FLASKR_SETTINGS file?

I want to use it like this way to override variables in my .py project

FILENAME='testfile.txt'

but it doesn't work

thanks

Is this in a Flask web app? I can't find any reference to that file in the Flask docs. How is it normally used?

I've seen it mentioned in the tutorial:

http://flask.pocoo.org/docs/tutorial/setup/#tutorial-setup

app.config.from_envvar('FLASKR_SETTINGS', silent=True)

That way someone can set an environment variable called FLASKR_SETTINGS to specify a config file to be loaded which will then override the default values. The silent switch just tells Flask to not complain if no such environment key is set.

Ah. I see. You can add this

app.config.from_object(__name__)

to your main flask python file. You'll need to add it just after this line:

app = Flask(__name__)

Then, any variables that are all in upper-case will be imported into the app confing.