python写了一个CGI脚本,为什么从网页看到的是脚本的内容
python写了一个脚本#!/usr/bin/envpythonprint"200OK"print"Content-Type:text/plain"print""prin...
python写了一个脚本
#!/usr/bin/env python
print "200 OK"
print "Content-Type: text/plain"
print ""
print "Hello CGI!"
---------------------------------------
通过python -m CGIHTTPServer启动8000端口进行监听
通过浏览器访问http://10.19.2.196:8000/cgi/help.py
为啥出来的结果是
而不是执行这个python脚本出来的内容? 展开
#!/usr/bin/env python
print "200 OK"
print "Content-Type: text/plain"
print ""
print "Hello CGI!"
---------------------------------------
通过python -m CGIHTTPServer启动8000端口进行监听
通过浏览器访问http://10.19.2.196:8000/cgi/help.py
为啥出来的结果是
而不是执行这个python脚本出来的内容? 展开
1个回答
展开全部
默认情况下,文件需要放在'/cgi-bin' 或 '/htbin'目录下,才会被解释执行,官方说法如下:
The do_GET() and do_HEAD() functions are modified to run CGI scripts
and serve the output, instead of serving files, if the request leads to
somewhere below the cgi_directories path.
The CGIHTTPRequestHandler defines the following data member:
cgi_directories
This defaults to ['/cgi-bin', '/htbin'] and describes directories to
treat as containing CGI scripts.
The do_GET() and do_HEAD() functions are modified to run CGI scripts
and serve the output, instead of serving files, if the request leads to
somewhere below the cgi_directories path.
The CGIHTTPRequestHandler defines the following data member:
cgi_directories
This defaults to ['/cgi-bin', '/htbin'] and describes directories to
treat as containing CGI scripts.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询