CGIHTTPRequestHandler
gives an import error saying no such module available.
import CGIHTTPServer
import BaseHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ["/cgi"]
PORT = 8000
httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
I get the following response.
Traceback (most recent call last):
File "D:/PYTHON/cgiserver.py", line 1, in <module>
from CGIHTTPServer import CGIHTTPRequestHandler
File "D:/PYTHON\CGIHTTPServer.py", line 9, in <module>
handler = CGIHTTPServer.CGIHTTPRequestHandler
AttributeError: 'module' object has no attribute 'CGIHTTPRequestHandler'
Rename
CGIHTTPServer.py
. (And don't forget to removeCGIHTTPServer.pyc
.)Otherwise it conflicts with the standard module
CGIHTTPServer
; prevents you to import the module.