下面是我尝试运行的cgi脚本:
print("Content-type: text/plain\n")
print("Hello, world!")启动此服务器后:
#! python3
import cgitb
cgitb.enable()
import http.server
from http.server import HTTPServer
from http.server import CGIHTTPRequestHandler
def run(server_class=HTTPServer, handler_class=CGIHTTPRequestHandler):
server_address=('',8002)
httpd=server_class(server_address, handler_class)
httpd.serve_forever()
if __name__ == '__main__':
run()发布于 2016-06-08 03:36:45
我不确定这个答案是否正确,但我将\ CGi -bin中的cgi脚本从hello.cgi重命名为hello.py,现在它可以正确运行,没有错误。我是从John Gaines Jr对"CGI脚本不可执行“的回答中得到这个想法的。
https://stackoverflow.com/questions/37667011
复制相似问题