inherit from httpserver and extend it here is how you would define multithreaded http server that only accepts connections from specific subnettryfrom http server import httpserver from socketserver import threadingmixin except importerrorfrom basehttpserver import httpserver from socketserver import threadingmixin python python class myhttpserver(threadingmixin,httpserver)def _init_ (self,addr,handler,subnet)httpserver _init_ (self,addr,handlerself subnet subnet def verify_request(selfrequestclient_address)hostport client_address if not host startswith(subnet)return false return httpserver verify_request(self,request,client_addressexample of how the server runs serv myhttpserver(('', )somehandler'serv serve_forever(the httpserver class only deals with the low-level http protocol to get the server to actually do anythingyou have to supply handler class there are two built-in handlers and base class that can be used for defining your own custom handling these are described next simplehttprequesthandler and cgihttprequesthandler two prebuilt web server handler classes can be used if you want to quickly set up simple stand-alone web server these classes operate independently of any third-party web server such as apache cgihttprequesthandler(requestclient_addressserverserves files from the current directory and all its subdirectories in additionthe handler will run file as cgi script if it' located in special cgi directory (defined by the cgi_directories class variable which is set to ['/cgi-bin''/htbin'by defaultthe handler supports getheadand post methods howeverit does not support http redirects (http code )which limits its use to only more simple cgi applications for security purposescgi scripts are executed with uid of nobody in python this class is defined in the cgihttpserver module simplehttprequesthandler(requestclient_addressserverserves files from the current directory and all its subdirectories the class provides support for head and get requestsrespectively all ioerror exceptions result in " file not founderror attempts to access directory result in " directory listing not supportederror in python this class is defined in the simplehttpserver module both of these handlers define the following class variables that can be changed via inheritance if desiredhandler server_version server version string returned to clients by defaultthis is set to string such as 'simplehttp/ lib fl ff