python - 使用 mod_wsgi 部署 Flask 应用程序

标签 python apache mod-wsgi flask web-deployment

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

apache 的错误日志:

[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

我说“一些路由”是因为身份验证(在“/”上)和重定向到“/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);
}

路由“_sse_stream”用作事件源的 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>

webchat.wsgi 文件:

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

部署到 mod_wsgi 的基本“hello world”应用运行正常。 我的 Flask 应用程序在使用集成到 Flask 中的开发服务器运行时表现良好。

最佳答案

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

flask.pocoo.org/docs/patterns/jquery

关于python - 使用 mod_wsgi 部署 Flask 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11832611/

相关文章:

python - 将电子邮件 'From' 字段的 pandas DataFrame 拆分为发件人姓名、电子邮件地址

performance - apache bench 中连接、处理、等待的定义

python - Apache + mod_wsgi - 来自同一浏览器的并行请求

php - 有没有办法在 PHP 5.4 旁边运行 PHP 5.3

python - Django、mod_wsgi 和虚拟环境

python - 烧杯 session 中的 last_accessed 时间始终为 None,但 _accessed_time 正在更改

Django 应用程序因几个并发请求而卡住

python - 如何计算文件中有多少行相同?

python - 在 Django 中,我如何在单个查询中根据不同的字段值获取总行数?

python - 运行时错误 : Error(s) in loading state_dict for Generator: Missing key(s) in state_dict