CGIHTTPServer and custom headers

Graham Ashton gashton at cmedltd.com
Thu Apr 4 09:20:44 EST 2002


I tried to use the CGIHTTPServer module to implement a simple server for
running a simple CGI that I'm developing. I thought "Great, this can be
a nice stand alone little test environment, without the need for
apache".

It worked fine until I wanted to send the browser a temporary redirect
header (i.e. 302 response code), or indeed anything other than a 200
response code.

In other words, the CGIHTTPRequestHandler class has this little nugget
in it, irrespective of what headers the script is actually sending back
to the browser:

  self.send_response(200, "Script output follows")

Unsurprisingly, this means the browser ignores my redirects.

Now I know that the CGIHTTPServer module isn't supposed to be used for
production use, and I know I could patch it myself if it was important
enough to me, but right now what I'd like is a (fully) Python solution
that doesn't involve me touching apache.

Can anybody recommend the most straightforward approach? My app is dead
simple and doesn't need speed or scalability. I'm currently browsing the
twisted docs, and the asyncore docs. Is there an easier way?

Thanks (by the way, I'm on Linux).

-- 
Graham Ashton






More information about the Python-list mailing list