我在OS X 10.6上使用了带有CGIHTTPRequestHandler的http.server,并且run_cgi()中的posix代码路径看起来不能正常工作。我从表单提交中调用位于/cgi-bin/test.py的位置。CGI不能与内置的Python 3.1一起使用http.server
对于今天下午比较好的部分,我在os.execve()第1058行接收到错误“OSError:[Errno 2] No such file or directory'',但现在它们是'OSError:[Errno 8] Exec格式错误'。我已经改变了太多,我不确定导致不同错误的原因,但无论如何do_POST()不适合我。
$ ./demon-local.py
Serving HTTP on 0.0.0.0 port 8000
localhost - - [27/Oct/2010 21:24:39] "POST /cgi-bin/test.py HTTP/1.1" 200 -
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/http/server.py", line 1058, in run_cgi
os.execve(scriptfile, args, os.environ)
OSError: [Errno 8] Exec format error
localhost - - [27/Oct/2010 21:24:39] CGI script exit status 0x7f00
我在pdb中运行代码,找不到变量scriptfile,args和os.environ有什么问题。一旦我到达调试器执行os.execve行似乎只是挂起,我不得不ctrl-C几次杀死一切。
有没有人有成功使用内置的CGIHTTPRequestHandler?
非常感谢, 克里斯
你想通过CGI运行什么? – 2010-10-28 02:03:23
响应POST请求的Python CGI脚本。 – 2010-10-28 15:39:02