1

Resolved

Flask app.py gets imported twice

description

Currently we have app.py creating the app, then routes.py imports app. When running w/ F5 this results in the app being created twice and replaced when we do from routes import . We should follow the getting large documentation and kill the import .

http://flask.pocoo.org/docs/patterns/packages/
Here’s an example __init__.py:


from flask import Flask
app = Flask(__name__)

import yourapplication.views


And this is what views.py would look like:


from yourapplication import app

@app.route('/')
def index():
    return 'Hello World!'


You should then end up with something like that:

/yourapplication
    /runserver.py
    /yourapplication
        /__init__.py
        /views.py
        /static
            /style.css
        /templates
            layout.html
            index.html
            login.html
            ...

comments