0

是否可以编写一个返回 php 应用程序输出的 wsgi ( werkzeug)应用程序?

详细地说,我有以下问题:我们有几个旧的遗留 php 应用程序,需要在它前面进行某种身份验证,由 wsgi 或任何其他 python 应用程序处理。

在虚拟代码中,它会像这样工作:

for every request:
    valid = check cookie or get-paramter
    if valid:
        return php application
    else:
        return "<html>you are not allowed</html>"

我知道 apache-mod_wsgi 有访问控制机制,但唯一允许返回 true 或 false。

有任何想法吗?

4

1 回答 1

0

googling for "python wsgi php", the first result I get is http://pythonpaste.org/wphp/ :

This module allows you to run PHP processes inside of Python, using a WSGI gateway.

but as you mention it never went further than alpha.

A braindead solution would be to serve the php application on a local IP and have your wsgi app just proxy to the php one via urllib, but you'll possibly have to postprocess the reponse body to fix urls etc.

于 2013-04-24T16:10:39.643 回答