I'm a beginner with python and I've been having a lot of trouble setting up the structure of my applications using __init__.py
even after searching through several tutorials.
At the moment, my current directory structure looks like the following
/parent
/myapp
__init__.py
views.py
/virtualenv
Previously, I had (if it makes any difference)
/parent
/myapp
/bin
/include
/lib
The contents of __init__.py
are below:
from flask import Flask
app = Flask(__name__)
and my views.py
from myapp import app
@app.route('/')
def test():
return 'This is a new test'
if __name__ == '__main__':
app.run(debug=True)
If myapp
is being initialized with the init file, why can't I call it into the views? I get an error stating 'I cannot import app and I have no module named myapp'. If I remove the init file and copy the contents into the top of the views.py file, everything works fine.