使用mod_wsgi部署烧瓶应用程序

Pau*_*aul 5 python apache mod-wsgi web-deployment flask

我正在尝试将我的一个Flask应用程序部署到apache上的mod_wsgi,但我遇到了麻烦,因为apache试图解决文件系统上的一些路由:

apache的error_log:

[Mon Aug 06 19:18:38 2012] [error] [client ::1] File does not exist: 
/srv/http/webchat/src/_publish_message, referer: http://localhost:88/webchat/chat
Run Code Online (Sandbox Code Playgroud)

我说的是"一些路由",因为身份验证(在"/"上)和重定向到"/ chat"有效.

路径"_publish_message"可以通过这样的AJAX访问(使用jQuery):

function publish_message(e){
    e.preventDefault();
    $.post('/_publish_message', {'message': "user's message taken from a text field"})
        .fail(Handler.publish_error);
}
Run Code Online (Sandbox Code Playgroud)

路径"_sse_stream"用作EventSource的URL.

这两个都不行!

虚拟主机配置:

<VirtualHost *:88>
    ServerName webchat.dev

    WSGIDaemonProcess webchat user=http group=http threads=5
    WSGIScriptAlias /webchat /srv/http/webchat/src/webchat.wsgi
    WSGIScriptReloading On

    DocumentRoot /srv/http/webchat/src

    <Directory /srv/http/webchat/src>
        WSGIProcessGroup webchat
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

webchat.wsgi文件中:

import sys
sys.path.insert(0, '/srv/http/webchat/src')
from index import app as application
Run Code Online (Sandbox Code Playgroud)

部署一个基本的"hello world"应用程序以mod_wsgi运行OK.我的烧瓶应用程序,当使用集成到烧瓶中的开发服务器运行时,表现良好.

cod*_*eek 2

使用此链接遵循正确的流程。您必须使用 $SCRIPT_ROOT 变量。

Flask.pocoo.org/docs/patterns/jquery