I'm trying to run flask on a server with passenger. This is my passenger_wsgi.py file:
import sys, os
INTERP = os.path.join(os.environ['HOME'], 'flask_env', 'bin', 'python')
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())
from wtf import app as application
# Uncomment next two lines to enable debugging
from werkzeug.debug import DebuggedApplication
application = DebuggedApplication(application, evalex=True)
There is an app.py file under wtf folder. There is also __init__.py
in there so python recognizes it as a module directory. However it gives me this error:
Traceback (most recent call last)
File "/home/hiepha19/flask_env/lib/python2.6/site-packages/werkzeug/debug/__init__.py", line 88, in debug_application
app_iter = self.app(environ, start_response)
TypeError: 'module' object is not callable
When you import app
you are importing the app
module (which most likely has an app
name inside it which points to your Flask app. What you want to do is import that name and register it:
from wtf.app import app as application
# Note the extra app
It is worth noting that you do not need to do this manually - simply run Flask using the run
method on the app and pass the argument debug=True
to get the same behavior:
from wtf.app import app
if __name__ == '__main__':
app.run(debug=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With