HTTP Location: supported by HTTPServer?

Will Stuyvesant hwlgw at hotmail.com
Thu Dec 4 12:34:39 EST 2003


I have a CGI server written in Python, useful for offline CGI testing.
 One of my CGI scripts ends with:

print 'Location: http://myresourcelocation'
print

But this does not work with the Python CGI server...and the same
script *does* work via internet with the Apache server at my work.

Does the BaseHTTPServer.HTTPServer not support the HTTP Location
header or something like that?


>From my Python CGI server program:



PORT = 8000

class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
    ##
    # Put subdirectories BEFORE their parent directories or else HTTP
    # error 403 (no permission).
    cgi_directories = ["/cgi-bin/mystuff", "/cgi-bin"]
    ##
    # A hack for quiet mode: don't want messages (what IP reads what
    # URL) to the console box
    def log_message(self, *msg): pass

def serve():
    httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
    print "serving at port", PORT
    httpd.serve_forever()

class CGIServer(threading.Thread):
    def run(self): serve()


if __name__=='__main__': 
    CGIServer().start()




More information about the Python-list mailing list