我在这里遵循说明:http: //flask.pocoo.org/snippets/65/
但是有些东西写的不是很清楚。
所以我的结构是这样的:
/<username>/webapps/flask/
----__init__.py
/<username>/webapps/flask/htdocs/
----index.py
----config.py
----/app/ (this is my flask application where i have views.py).
----/tmp/
我的__init__.py:
class WebFactionMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
environ['SCRIPT_NAME'] = '/app'
return self.app(environ, start_response)
app.wsgi_app = WebFactionMiddleware(app.wsgi_app)
我的index.py:
从烧瓶导入应用程序作为应用程序
我的httpd.conf:
WSGIPythonPath /home/<username>/webapps/flask/htdocs/
#If you do not specify the following directive the app *will* work but you will
#see index.py in the path of all URLs
WSGIScriptAlias /app /home/<username>/webapps/flask/htdocs/index.py
<Directory /home/<username>/webapps/flask/htdocs>
AddHandler wsgi-script .py
RewriteEngine on
RewriteBase /app
WSGIScriptReloading On
</Directory>
我从控制面板安装为“wsgi 3.4/Python2.7”,但我必须使用easy-install2.6安装SSH SQLAlchemy、flask-login等,因为easy-install2.7不存在。
服务器错误日志说:
from flask import app as application
[Sun Nov 04 23:29:12 2012] [error] [client 127.0.0.1] ImportError: No module named flask
(我确实重启了apache2)