<p dir="auto"><a href="http://flask.pocoo.org/docs/0.11/cli/" rel="nofollow">The docs</a> on the FLASK_APP variable state that</p>
<blockquote>
<p dir="auto">In that imported file the name of the app needs to be called <code class="notranslate">app</code> or optionally be specified after a colon. For instance <em>mymodule:application</em> would tell it to use the <em>application</em> object in the <code class="notranslate">mymodule.py</code> file.</p>
</blockquote>
<p dir="auto">However, creating the following script (run.py):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from flask import Flask

webapp = Flask(__name__)"><pre class="notranslate"><code class="notranslate">from flask import Flask

webapp = Flask(__name__)
</code></pre></div>
<p dir="auto">setting <code class="notranslate">FLASK_APP=run.py:webapp</code>, and running <code class="notranslate">flask run</code> gives me an ImportError:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py&quot;, line 156, in __call__
    self._flush_bg_loading_exception()
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py&quot;, line 144, in _flush_bg_loading_exception
    reraise(*exc_info)
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/_compat.py&quot;, line 33, in reraise
    raise value
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py&quot;, line 133, in _load_app
    self._load_unlocked()
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py&quot;, line 148, in _load_unlocked
    self._app = rv = self.loader()
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py&quot;, line 209, in load_app
    rv = locate_app(self.app_import_path)
  File &quot;/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py&quot;, line 89, in locate_app
    __import__(module)
ImportError: No module named 'run'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py", line 156, in __call__
    self._flush_bg_loading_exception()
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py", line 144, in _flush_bg_loading_exception
    reraise(*exc_info)
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py", line 133, in _load_app
    self._load_unlocked()
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py", line 148, in _load_unlocked
    self._app = rv = self.loader()
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py", line 209, in load_app
    rv = locate_app(self.app_import_path)
  File "/Users/me/app/venv/lib/python3.5/site-packages/flask/cli.py", line 89, in locate_app
    __import__(module)
ImportError: No module named 'run'
</code></pre></div>
<p dir="auto">Interestingly, using <code class="notranslate">FLASK_APP=run.py</code> actually works even with the app named "webapp". So while I'm not sure how much of this is error on my part vs. error on flask's, the docs are wrong in saying that the Flask object <em>needs</em> to be named "app".</p>
<p dir="auto">Example project that shows issue is available here: <a href="https://github.com/sean-lynch/flask-cli-issue">https://github.com/sean-lynch/flask-cli-issue</a> . I'm not sure if this is a flask cli issue or an issue with documentation. Happy to correct the docs if it's the latter.</p>
<p dir="auto">I'm attempting to use the large app structure seen in the <a href="http://flask.pocoo.org/docs/0.11/patterns/packages/" rel="nofollow">Flask Larger Applications documentation</a></p>
<p dir="auto">First, set up a virutal environment and install flask 0.11 into that environment (requirements.txt<br>
has all that for you).</p>
<p dir="auto">Can successfully launch app using old <code class="notranslate">app.run()</code> mechanism found in <code class="notranslate">run.py</code> and <code class="notranslate">old_launch.sh</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ python run.py"><pre class="notranslate"><code class="notranslate">$ python run.py
</code></pre></div>
<p dir="auto">But can't seem to get to work with flask-cli. You can see both of the methods in <code class="notranslate">new_launch.sh</code>.</p>
<p dir="auto">This throws <code class="notranslate">ImportError - No module named server</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ FLASK_APP=server FLASK_DEBUG=1 flask run"><pre class="notranslate"><code class="notranslate">$ FLASK_APP=server FLASK_DEBUG=1 flask run
</code></pre></div>
<p dir="auto">This loads, but doesn't register any of the views even though the <code class="notranslate">Loading views...</code> print output makes it to the console.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ FLASK_APP=server/__init__.py FLASK_DEBUG=1 flask run"><pre class="notranslate"><code class="notranslate">$ FLASK_APP=server/__init__.py FLASK_DEBUG=1 flask run
</code></pre></div>
<p dir="auto">How should I be loading a module with flask-cli? Or alternatively, how should I be changing the module structure to support it properly?</p>