[Pythonmac-SIG] CGIHTTPServer problems on OS X

Kevin Altis altis@semi-retired.com
Fri, 14 Jun 2002 12:14:20 -0700


I've been trying to use a variation of the basic built-in Python web server
like this:

import os
from BaseHTTPServer import HTTPServer
from CGIHTTPServer  import CGIHTTPRequestHandler

os.chdir("html")
# my hostname, portnumber
srvraddr = ('', 80)
srvrobj  = HTTPServer(srvraddr, CGIHTTPRequestHandler)
# run as perpetual demon
srvrobj.serve_forever()

The actual code I'm testing is the GUI front-end included with PythonCard,
but this problem seems to be with CGIHTTPServer not wxPython or any GUI
code.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pythoncard/PythonCardPrototyp
e/samples/webserver/

Serving files works fine, but I can't get CGIs to work. The error I'm
getting is (partial traceback)

CGIHTTPServer, line 65, in send_head, return self.run_cgi()

CGIHTTPServer, line 196, in run_cgi, self.rfile.flush() # Always flush
before forking
IOError: [Errno 9] Bad file descriptor

I'm using the latest MachoPython build from:

http://sourceforge.net/project/showfiles.php?group_id=10718

BTW, if you run at a low port number like 80, you'll have to use sudo to
start the server, so it might be simpler to try a high port like 8000. Are
simple CGIs are working for other people using the Python built-in
libraries?

ka
----------------------
Kevin Altis
altis@semi-retired.com