2010-10-28 27 views
0

我在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?

非常感謝, 克里斯

+0

你想通過CGI運行什麼? – 2010-10-28 02:03:23

+0

響應POST請求的Python CGI腳本。 – 2010-10-28 15:39:02

回答

-2

爲什麼你會用Python語言編寫CGI腳本,然後使用一個Python Web服務器做CGI電話!?談論通過針眼強迫駱駝。

直接從Python調用Python方法。在Python 3.2中,甚至應該有一個參考WSGI實現。或者你可以看看瓶框架,它支持Python 3.