WSGI 应用程序包装器

许多 Flask 应用程序是在 virtualenv 中开发的,以便将每个应用程序的依赖关系与系统范围的 Python 安装分开。确保你的 virtualenv 中安装了 mod-wsgi : **

pip install mod-wsgi

然后为 Flask 应用程序创建一个 wsgi 包装器。通常它保存在应用程序的根目录中。

我 -application.wsgi

activate_this = '/path/to/my-application/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '/path/to/my-application')

from app import app as application

当从 Apache 运行时,此包装器激活虚拟环境及其所有已安装的模块和依赖项,并确保应用程序路径位于搜索路径中的第一位。按照惯例,WSGI 应用程序对象称为 application