This is not the way! My recommendation is to create some Python configuration module (say config.py
) with some content, for example:
DEBUG = True
Now in our current code write:
import config app.run(debug=config.DEBUG)
Now that you start production, just change DEBUG
from True
to False
. Or you can leave this file unversioned, so the development copy is different from the production copy. This is not uncommon, because, for example, the same database connection parameters are not used both in development and in production.
Even if you want to update it automatically, just call sed in the configuration file with the -i
flag. It is safer to update only one file:
$ sed -i.bkp 's/^ *DEBUG *=.*$/DEBUG = False/' config.py
source share