[Flask] I'm missing something about these Flask cookiecutter template

Skip Montanaro skip.montanaro at gmail.com
Mon Apr 17 14:28:19 EDT 2017


I'm casting about for a useful Flask template for more serious
applications. I've done one or two very small Flask apps manually, but
thought it would be nice to see what sort of structures people use for more
complex stuff.

I installed cookiecutter into my Anaconda environment. (That was a chore
because anaconda.org keeps complaining that I'm not authorized
<https://github.com/conda/conda/issues/3399>, so I had to download and
install it and its dependencies manually. Not great fun.) Then I
instantiated this template:

https://github.com/sloria/cookiecutter-flask

and answered the simple questions it asked (name, title, description, etc.)
Then, looking at these instructions:

https://github.com/sloria/cookiecutter-flask/blob/master/%7B%7Bcookiecutter.app_name%7D%7D/README.rst#quickstart

I saw a bit more than I hoped for. So far, in my trivial applications, I've
just run from the repo (no installation). I figured this would be all I
needed:

export {{cookiecutter.app_name | upper}}_SECRET='something-really-secret'
export FLASK_APP=/path/to/autoapp.py
export FLASK_DEBUG=1
flask run

When I visit the app's URL, I keep getting

flask.cli.NoAppException: The file/path provided (manage) does not appear
to exist.  Please verify the path is correct.  If app is not on PYTHONPATH,
ensure the extension is .py

So I tried another template:

https://github.com/JackStouffer/cookiecutter-Flask-Foundation

Same drill. Answer the questions, set the FLASK environment variables, run
the flask app:

(anaconda) stouffer-flask% pwd
/home/skip/src/stouffer-flask
(anaconda) stouffer-flask% cd defunct_archiver/
(anaconda) defunct_archiver% ls
defunct_archiver  manage.py    README.md         tests
Makefile          __pycache__  requirements.txt
(anaconda) defunct_archiver% export FLASK_APP=${PWD}/manage.py
(anaconda) defunct_archiver% export FLASK_DEBUG=1
(anaconda) defunct_archiver% flask run
 * Serving Flask app "manage"
 * Forcing debug mode on
/home/skip/src/stouffer-flask/defunct_archiver/manage.py:5:
ExtDeprecationWarning: Importing flask.ext.script is deprecated, use
flask_script instead.
  from flask.ext.script import Manager, Server
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
/home/skip/src/stouffer-flask/defunct_archiver/manage.py:5:
ExtDeprecationWarning: Importing flask.ext.script is deprecated, use
flask_script instead.
  from flask.ext.script import Manager, Server
 * Debugger is active!
 * Debugger PIN: 104-595-126

Then I visit http://127.0.0.1:5000/ and get the same 500 response.

127.0.0.1 - - [17/Apr/2017 13:23:39] "GET / HTTP/1.1" 500 -
Traceback (most recent call last):
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/cli.py",
line 178, in __call__
    self._flush_bg_loading_exception()
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/cli.py",
line 166, in _flush_bg_loading_exception
    reraise(*exc_info)
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/_compat.py",
line 33, in reraise
    raise value
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/cli.py",
line 155, in _load_app
    self._load_unlocked()
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/cli.py",
line 170, in _load_unlocked
    self._app = rv = self.loader()
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/cli.py",
line 231, in load_app
    rv = locate_app(self.app_import_path)
  File
"/home/skip/anaconda3/envs/anaconda/lib/python3.6/site-packages/flask/cli.py",
line 95, in locate_app
    'is .py' % module)
flask.cli.NoAppException: The file/path provided (manage) does not appear
to exist.  Please verify the path is correct.  If app is not on PYTHONPATH,
ensure the extension is .py

Shouldn't I be able to bring up one of these skeletal Flask apps from my
local repo without having to go through the labor of packaging and
installing it? Is there some underlying exception getting raised and tossed
in favor of the higher level NoAppException? If so, is there some way to
get at it?

Thx,

Skip Montanaro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170417/85f82e23/attachment.html>


More information about the Flask mailing list