Skip to content
Myr

Enable template auto-reloading in app.run()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

When Flask app debugging is enabled (app.debug==True), and Jinja2 template auto-reloading is not explicitly disbaled, template auto-reloading should be enabled. If the app is instantiated, the jinja_env object is accessed (thereby initialising the Jinja2 environment) and the server is then started with app.run(debug=True), template auto-reloading is *not* enabled. This is because reading the jinja_env object causes the environment initialisation function to set auto_reload to app.debug (which isn't yet True). Calling app.run(debug=True) should correct this in order to remain consistent with Flask code reloading (which is enabled within app.run() if debug == True).

authored by Dave Barker · committed by Dave Barker · parent 433c561 · Browse files · 1 file+2 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−0 removed

  • other:+2 added−0 removed

1 file+2 added−0 removed

modified:flask/app.py+2 added
837 unmodified lines
838 self.debug = bool(debug)839 options.setdefault('use_reloader', self.debug)840 options.setdefault('use_debugger', self.debug)841 options.setdefault('passthrough_errors', True)842 if debug:843 self.jinja_env.auto_reload = True844 try:845 run_simple(host, port, self, **options)846 finally:847 # reset the first request information if the development server
1161 unmodified lines