Flask suggests the following file layout:

    runflaskapp.py
    flaskapp/
        __init__.py

runflaskapp.py contains:

    from flaskapp import app
    app.run(debug=True)

flaskapp/__init__.py contains:

    from flask import Flask
    app = Flask(__name__)

Running this with 'python3 runflaskapp.py' works fine. However it
seems to me that a more Python3onic way of doing this would be to
rename 'runflaskapp.py' as 'flaskapp/__main__.py' and then run
the whole thing as 'python3 -m flaskapp'. Unfortunately this doesn't
work:

    $ python3 -m flaskapp
     * Running on http://127.0.0.1:5000/
     * Restarting with reloader
    Traceback (most recent call last):
      File "/home/username/src/flaskapp/__main__.py", line 1, in <module>
        from flaskapp import app
    ImportError: No module named 'flaskapp'

Does anyone know why and how to fix it?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to