title: Flask and gunicorn, multiple modules: circular imports - not all routes accessible
body: <p>My problem is similar to <a href="https://stackoverflow.com/questions/16206413/flask-and-gunicorn-on-heroku-import-error">Flask and Gunicorn on Heroku import error</a> and <a href="https://stackoverflow.com/questions/10670958/procfile-gunicorn-custom-module-name">Procfile gunicorn custom module name</a> but I can't seem to fix it using their solutions.</p>
  
  <p>My Flask app has the following structure:</p>
  
  <pre><code>appname/
     run.py
     Procfile
     venv/
         ...
     appname/
         app.py
         views.py
  </code></pre>
  
  <p>run.py:</p>
  
  <pre><code>from appname import app
  app.run(debug=True)
  </code></pre>
  
  <p>app.py:</p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  @app.route('/')
  def home():
      return "here"
  </code></pre>
  
  <p>Procfile:</p>
  
  <pre><code>web: gunicorn --pythonpath appname app:app
  </code></pre>
  
  <p>views.py:</p>
  
  <pre><code>from appname import app
  from flask import render_template
  
  @app.route('/there')
  def there():
      return "there"
  </code></pre>
  
  <p>Previously, I was experiencing erorrs when running <code>foreman start</code>, but those went away once I removed <code>import appname.views</code> from <code>app.py</code>.</p>
  
  <p><strong>Now, <code>foreman start</code> runs the app and route <code>/</code> is accessible but <code>/there</code> is not. How come?</strong></p>