Flask - Setting root directory
Question: I have a folder structure that looks like so:

    
    
    myproject/
        - flask_app/
            - app.py
            - templates/
        - module1.py
        - module2/
            - db.py
            - models/
    

I'm running into ImportErrors in my Flask application when trying to do the
following:

    
    
    from module2 import db
    # or something else like
    import module1
    
    from flask import Flask
    app = Flask(__name__)
    
    if __name__ == "__main__":
        app.run(debug=True)
    

This is obviously because the Flask app is running from its own subdirectory
"flask_app". I normally would try and get around this by running it like so:

    
    
    python -m flask_app.app
    

But this doesn't seem to solve the problem.

Is there a way I run my flask app from the root folder without resorting to
relative imports (using older version of Python)


Answer: When you run `python -m flask_app.app`, most likely `sys.path` won't include
the `myproject` path.

Easiest would be to put a top-level script in the `myproject` directory; lets
call it `runsite.py`:

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

and run that with Python:

    
    
    $ python runsite.py
    

