def do_GET(self): self.log.log(cpc.util.log.TRACE, '%s %s' % (self.command, self.path)) # if the path starts with application root + / or ? we have a message to process #otherwise we should just strip any request params and keep the resource reference if (self.isApplicationRoot()): request = HttpMethodParser.parseGET(self.headers.dict, self.path) self.processMessage(request) #take the input and put it into a request object else: if self.path == "/": self.path += "index.html" else: self.path = self.path.split('?', 1)[0] #strip trailing '?...' webDir = ServerConf().getWebRootPath() resourcePath = webDir + self.path if not os.path.isfile(resourcePath): self.responseCode = 404 resourcePath = webDir + '/404.html' response = ServerResponse() file = open(resourcePath, 'rb') response.setFile(file, mimetypes.guess_type(resourcePath)) self._sendResponse(response)
def do_GET(self): self.log.log(cpc.util.log.TRACE,'%s %s'%(self.command,self.path)) # if the path starts with application root + / or ? we have a message to process #otherwise we should just strip any request params and keep the resource reference if(self.isApplicationRoot()): request = HttpMethodParser.parseGET(self.headers.dict,self.path) self.processMessage(request) #take the input and put it into a request object else: if self.path == "/" : self.path += "index.html" else: self.path = self.path.split('?', 1)[0]#strip trailing '?...' webDir = ServerConf().getWebRootPath() resourcePath = webDir+self.path if not os.path.isfile(resourcePath): self.responseCode = 404 resourcePath = webDir+'/404.html' response = ServerResponse() file = open(resourcePath,'rb') response.setFile(file, mimetypes.guess_type(resourcePath)) self._sendResponse(response)