internet application programming handler extensions_map dictionary mapping suffixes to mime types unrecognized file types are considered to be of type 'application/octet-streamhere is an example of using these handler classes to run stand-alone web server capable of running cgi scriptstryfrom http server import httpservercgihttprequesthandler python except importerrorfrom basehttpserver import httpserver python from cgihttpserver import cgihttprequesthandler import os change to the document root os chdir("/home/httpd/html"start the cgihttp server on port serv httpserver(("", ),cgihttprequesthandlerserv serve_forever(basehttprequesthandler the basehttprequesthandler class is base class that' used if you want to define your own custom http server handling the prebuilt handlers such as simplehttprequesthandler and cgihttprequesthandler inherit from this in python this class is defined in the basehttpserver module basehttprequesthandler(requestclient_addressserverbase handler class used to handle http requests when connection is receivedthe request and http headers are parsed an attempt is then made to execute method of the form do_request based on the request type for examplea 'getmethod invokes do_get(and 'postmethod invokes do_post by defaultthis class does nothingso these methods are expected to be defined in subclasses the following class variables are defined for basehttprequesthandler and can be redefined in subclasses basehttprequesthandler server_version specifies the server software version string that the server reports to clients--for example'servername/ basehttprequesthandler sys_version python system versionsuch as 'python/ basehttprequesthandler error_message_format format string used to build error messages sent to the client the format string is applied to dictionary containing the attributes codemessageand explain for example''error response error response error code %(code) message%(message) error code explanation%(code) %(explain) '' lib fl ff