I'm following this tutorial to build a user login system within Flask using Python 2.7.
Intro to Flask: Signing In and Out
I have this Flask application structure.
flaskapp/
└── app/
├── user/
│ ├── __init__.py
│ ├── static/
│ ├── templates/
│ ├── forms.py
│ ├── routes.py
└── runserver.py
Within the tutorial, it has me edit this file.
app/intro_to_flask/routes.py
Within that file you have this code.
from user import app
from flask import render_template, request, flash
from forms import ContactForm
from flask.ext.mail import Message, Mail
mail = Mail()
.
.
.
# @app.route() mappings start here
I get this error.
ImportError: cannot import name app
That being said, I cannot do from user import app. I've tried:
from . import app
I don't really know how to explain the question here, but I am editing a python file within the user directory that is trying to import an outer directory within itself? How can you possibly do from user import app if the app directory does not live within the user directory? What am I missing here?
Within the runserver.py, I'm able to do it because I assume runserver.py lives in the app directory. I cannot do it in routes.py though.
If I cannot import app, I cannot define routes within Flask as such:
@app.route('/')
def index():
return "Testing route!"