【问题标题】:Python get URL from ApachePython 从 Apache 获取 URL
【发布时间】:2012-10-08 15:50:32
【问题描述】:

我使用 Apache2 作为我的网络服务器,并使用 mod_python 作为它的“解释器”。如何获取当前的 url 参数?例如:/cgi-bin/test.py?set=12

我想根据 URL 中发布的值进行操作。我查看了urlparse 库,但这需要 URL,我还没有。

【问题讨论】:

  • mod_python 已死并被埋葬。请改用mod_wsgi
  • 确实——比直接使用 mod_wsgi(由 mod_python 的 ex-last-maintainer 编写)更好——你最好使用 Python Web 应用程序的框架,而不是尝试将一个脚本绑定到Web 服务器只使用 Python 的 Web 服务器插件。

标签: python apache python-2.7


【解决方案1】:
def index():  
    return "Python works!"

def command(command):  
    return "this is a command %s!" %command

正常调用页面时索引返回字符串

test.py/command?command=foo 将返回 foo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2013-09-15
    • 2015-03-23
    • 2021-06-30
    • 2011-10-19
    • 2011-08-02
    • 1970-01-01
    相关资源
    最近更新 更多