在Apache代理下运行Flask jQuery示例

在Apache代理下运行Flask jQuery示例,jquery,python,apache,flask,mod-proxy,Jquery,Python,Apache,Flask,Mod Proxy,我可以成功地运行(如页面底部所述)。它在flask开发服务器上运行,可在http://localhost:5000 如何代理页面,以便在http://localhost/jqueryexample 我将此添加到我的Apache VirtualHost条目中,认为它可以实现以下目的: ProxyPass /jqueryexample http://localhost:5000/ ProxyPassReverse /jqueryexample http://localhost:5000/ 但是新的

我可以成功地运行(如页面底部所述)。它在flask开发服务器上运行,可在
http://localhost:5000

如何代理页面,以便在
http://localhost/jqueryexample

我将此添加到我的Apache VirtualHost条目中,认为它可以实现以下目的:

ProxyPass /jqueryexample http://localhost:5000/
ProxyPassReverse /jqueryexample http://localhost:5000/
但是新的URL给出了404错误:

GET http://localhost/_add_numbers?a=6&b=2 404 (Not Found)
如何让示例在“规范URL”(不确定这是否是正确的术语)下正确运行?或者,如何更改应用程序或Apache配置以使jQuery示例在两个URL上运行


顺便说一句,以下是您如何下载和运行所讨论的香草:

git clone http://github.com/mitsuhiko/flask 
cd flask/examples/jqueryexample/ 
python jqueryexample.py

我面前没有Apache安装,但是如果你正在代理应用程序,你不应该将index.html的第6行从

$.getJSON($SCRIPT_ROOT + '/_add_numbers', {


好的,在进一步研究之后,我想我回答了我自己的问题:

git clone http://github.com/mitsuhiko/flask 
cd flask/examples/jqueryexample/ 
python jqueryexample.py
显然,与其运行flask开发服务器并尝试通过ApacheHttpd代理它,不如使用mod_wsgi将应用程序直接部署到Apache。关于如何做到这一点的指导方针有很好的文档记录。事实上,对于生产环境,根本不推荐使用dev服务器(请参阅)

至于部署本身,下面是您要做的(假设您的DocumentRoot是
/var/www/html
):

现在将此添加到VirtualHost:

WSGIScriptAlias /jqueryexample /var/www/html/jqueryexample/jqueryexample.wsgi
<Location /var/www/html/jqueryexample>
    Allow from all
    Order allow,deny
</Location>
WSGIScriptAlias/jqueryexample/var/www/html/jqueryexample/jqueryexample.wsgi
通融
命令允许,拒绝

然后重新启动httpd。现在在
http://localhost/jqueryexample
。瞧

谢谢,但不起作用-没有错误,但它不运行
\u add\u numbers
服务。此外,现在
http://localhost:5000
给出了404错误。
WSGIScriptAlias /jqueryexample /var/www/html/jqueryexample/jqueryexample.wsgi
<Location /var/www/html/jqueryexample>
    Allow from all
    Order allow,deny
</Location>