首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Python 的CGIHTTPServer服务器不实施.py脚本

2012-09-11 
Python 的CGIHTTPServer服务器不执行.py脚本大家好,我在windows XP系统下输入命令 python -m CGIHTTPServe

Python 的CGIHTTPServer服务器不执行.py脚本
大家好,我在windows XP系统下输入命令 python -m CGIHTTPServer 搭建了CGI服务器
测试脚本为

Python code
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之间有一个空行,也就是两个换行。

热点排行