title: Reload Flask app when template file changes
body: <p>By default, when running Flask application using the built-in server (<code>Flask.run</code>), it monitors its Python files and automatically reloads the app if its code changes:</p>
  
  <pre><code>* Detected change in '/home/xion/hello-world/app.py', reloading
  * Restarting with reloader
  </code></pre>
  
  <p>Unfortunately, this seems to work for <em>*.py</em> files only, and I don't seem to find any way to extend this functionality to other files. Most notably, it would be extremely useful to have Flask restart the app when a <strong>template</strong> changes. I've lost count on how many times I was fiddling with markup in templates and getting confused by not seeing any changes, only to find out that the app was still using the old version of Jinja template.</p>
  
  <p>So, is there a way to have Flask monitor files in <em>templates</em> directory, or does it require diving into the framework's source?</p>
  
  <p><strong>Edit</strong>: I'm using Ubuntu 10.10. Haven't tried that on any other platforms really.</p>
  
  <hr>
  
  <p>After further inquiry, I have discovered that changes in templates indeed <em>are</em> updated in real time, without reloading the app itself. However, this seems to apply only to those templates that are passed to <code>flask.render_template</code>.</p>
  
  <p>But it so happens that in my app, I have quite a lot of reusable, parametrized components which I use in Jinja templates. They are implemented as <code>{% macro %}</code>s, reside in dedicated "modules" and are <code>{% import %}</code>ed into actual pages. All nice and DRY... except that those imported templates are apparently never checked for modifications, as they don't pass through <code>render_template</code> at all.</p>
  
  <p>(Curiously, this doesn't happen for templates invoked through <code>{% extends %}</code>. As for <code>{% include %}</code>, I have no idea as I don't really use them.)</p>
  
  <p>So to wrap up, the roots of this phenomenon seems to lie somewhere between Jinja and Flask or Werkzeug. I guess it may warrant a trip to bug tracker for either of those projects :) Meanwhile, I've accepted the <em>jd.</em>'s answer because that's the solution I actually used - and it works like a charm.</p>