【发布时间】:2015-05-02 13:44:49
【问题描述】:
我正在尝试使用 mod_python 配置 apache 以运行 python 脚本。我尝试了许多不同的配置,但都没有奏效。我的 hello.py 文件看起来像这样
from mod_python import apache
def handler(req):
req.log_error('handler')
req.content_type = 'text/html'
req.send_http_header()
req.write('<html><head><title>Testing mod_python</title></head> <body>')
req.write('Hello World!')
req.write('</body></html>')
return apache.OK
我已将 hello.py 文件放在 /var/www/html 文件夹中,每当我输入 http://localhost/hello 时,就会出现 404 file not found 错误,当我也在 url http://localhost/hello.py 中输入扩展名时,就会出现 hello 的全部内容。 py 文件显示在我的浏览器中。 提前致谢。
【问题讨论】:
标签: python apache mod-python