当我将http://localhost:8888/cgi-bin/peoplecgi.py?action=Fetch&key=sue(sue 是搁置中的有效密钥)发送到下面的 cgi 脚本时,我得到以下信息(我也在使用 Python 3.3 的 OSX 上)。任何想法出了什么问题?
127.0.0.1 - - [04/Feb/2014 10:38:41] "GET /cgi-bin/peoplecgi.py?action=Fetch&key=sue HTTP/1.1" 200 -
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/http/server.py", line 1131, in run_cgi
os.execve(scriptfile, args, env)
OSError: [Errno 8] Exec format error: '/Users/rich/Google Drive/Code/Python/PP4E/Preview/cgi-bin/peoplecgi.py'
127.0.0.1 - - [04/Feb/2014 10:38:41] CGI script exit status 0x7f00
Run Code Online (Sandbox Code Playgroud)
我正在使用 O'Reilly 的 Python 编程第 4 版。这是问题基于示例 1-33。
weberver.py:
import os, sys
from http.server import HTTPServer, CGIHTTPRequestHandler
webdir = '/Users/rich/Google Drive/Code/Python/PP4E/Preview/'
port = 8888
os.chdir(webdir)
srvraddr = …Run Code Online (Sandbox Code Playgroud)