So I have been able to successfully create a basic site based on Flask with a single module (mysite.py) and some template files in a template directory. As my code continues to get more complicated, I am now trying to split things out so that the application module is easier to read. After running into issues, I went back to the basics and did the following:
- Created a new site - Manual Configuration
- Setup virtualenv
- Installed flask
I then setup my files as follows:
├── mysite
│ ├── app
│ │ └── views.py
├── flask_app.py
flask_app.py
from app.views import app
app.run(debug=True)
views.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello from Flask!'
wsgi file
activate_this = '/home/tkuehn/.virtualenvs/superapp/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
project_home = u'/home/tkuehn/mysite'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
from flask_app import app as application
After all this, my site produces the error: "Unhandled Exception" and generates the following in the error log: ImportError: No module named app.views
I feel like I am making a very basic error. Can anyone point me in the right direction? Thanks!