title: Auto reloading Flask app when source code changes
body: <p>I know for a fact that Flask, in debug mode, will detect changes to .py source code files and will reload them when new requests come in.</p>
  
  <p>I used to see this in my app all the time.  Change a little text in an @app.route decoration section in my views.py file, and I could see the changes in the browser upon refresh.</p>
  
  <p>But all of a sudden (can't remember what changed), this doesn't seem to work anymore.</p>
  
  <p>Q: Where am I going wrong?</p>
  
  <p>I am running on a OSX 10.9 system with a VENV setup using Python 2.7.  I use <code>foreman start</code> in my project root to start it up.</p>
  
  <p>App structure is like this:</p>
  
  <pre><code>[Project Root]
  +-[app]
  | +-__init__.py
  | +- views.py
  | +- ...some other files...
  +-[venv]
  +- config.py
  +- Procfile
  +- run.py
  </code></pre>
  
  <p>The files look like this:
  </p>
  
  <pre><code># Procfile
  web: gunicorn --log-level=DEBUG run:app
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code># config.py
  contains some app specific configuration information.
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code># run.py
  from app import app
  
  if __name__ == "__main__":
      app.run(debug = True, port = 5000)
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code># __init__.py
  from flask import Flask
  from flask.ext.login import LoginManager
  from flask.ext.sqlalchemy import SQLAlchemy
  from flask.ext.mail import Mail
  import os
  
  app = Flask(__name__)
  app.config.from_object('config')
  
  db = SQLAlchemy(app)
  
  #mail sending
  mail = Mail(app)
  
  lm = LoginManager()
  lm.init_app(app)
  lm.session_protection = "strong"
  
  from app import views, models
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code># app/views.py
  @app.route('/start-scep')
  def start_scep():
      startMessage = '''\
  &lt;html&gt;
  &lt;header&gt;
  &lt;style&gt;
  body { margin:40px 40px;font-family:Helvetica;}
  h1 { font-size:40px; }
  p { font-size:30px; }
  a { text-decoration:none; }
  &lt;/style&gt;
  &lt;/header&gt;
  
  &lt;p&gt;Some text&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;\
  '''
      response = make_response(startMessage)
      response.headers['Content-Type'] = "text/html"
      print response.headers
      return response
  </code></pre>