Python 的CGIHTTPServer服务器不施行.py脚本
Python 的CGIHTTPServer服务器不执行.py脚本大家好,我在windows XP系统下输入命令 python -m CGIHTTPServe
Python 的CGIHTTPServer服务器不执行.py脚本
大家好,我在windows XP系统下输入命令 python -m CGIHTTPServer 搭建了CGI服务器
测试脚本为
print "Content-Type: text/html"
print r'<p> Hello word!'
然后输入:http://localhost:8000/test.py
得到的结果为:
print "Content-Type: text/html"
print r'<p> Hello word!'
可见脚本并没有执行,如何解决呢?
我用的Python是 Python 2.5.2
[解决办法]python -m CGIHTTPServer test.py
[解决办法]http://docs.python.org/library/cgihttpserver.html
你的文件要放在cgi-bin目录下。
另外第一个print后面少了个换行。HTTP协议header和body之间有一个空行,也就是两个换行。