【发布时间】:2012-05-10 21:34:51
【问题描述】:
当我在 shell 中运行 python -m SimpleHTTPServer 8000 或 python -m CGIHTTPServer 8000 时,我将当前目录的内容托管到 Internet。
当我浏览到192.xxx.x.xx:8000/cgi_script.py时,我想在命令行中使用上述命令使以下cgi_script.py正常工作
#!/usr/bin/env python
print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""
但是这个脚本是按字面意思显示的,而不仅仅是“Hello World!”部分。 顺便说一句,我将 cgi_script.py 以及我托管它的文件夹的文件权限更改为 755。
【问题讨论】:
-
对于在 mac 或 linux 上尝试此操作的人,请确保具有允许执行文件的权限。换句话说:
chmod +x cgi-bin/cgi_script.py
标签: python hosting cgi simplehttpserver