def render(self, request): path = self.path if os_path.isfile(path): lastComponent = path.split('/')[-1] # Set the Header according to what's requested request.setResponseCode(http.OK) if lastComponent in AppTextHeaderFiles: request.setHeader('Content-Type', 'application/text') elif lastComponent in TextHtmlHeaderFiles or (path.endswith(".html.xml") and lastComponent != "updates.html.xml"): request.setHeader('Content-Type', 'text/html; charset=UTF-8') elif lastComponent not in NoExplicitHeaderFiles: request.setHeader('Content-Type', 'application/xhtml+xml; charset=UTF-8') # now go and write the Output # request.finish() is called inside webif.py (requestFinish() which is called via renderPage()) webif.renderPage(request, path, self.session) # login? elif os_path.isdir(path) and self.addSlash is True: return self.getChild("/", request).render(request) else: request.setResponseCode(http.NOT_FOUND) request.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n') request.write("<html><head><title>Enigma2 WebControl</title></head><body><h1>404 - Page not found</h1></body></html>") request.finish() return server.NOT_DONE_YET
def render(self, request): path = self.path if os_path.isfile(path): lastComponent = path.split('/')[-1] # Set the Header according to what's requested if lastComponent in AppTextHeaderFiles: request.setHeader('Content-Type', 'application/text') elif lastComponent in TextHtmlHeaderFiles or (path.endswith(".html.xml") and lastComponent != "updates.html.xml"): request.setHeader('Content-Type', 'text/html; charset=UTF-8') elif lastComponent in TextJavascriptHeaderFiles: request.setHeader('Content-Type', 'text/javascript; charset=UTF-8') elif lastComponent not in NoExplicitHeaderFiles: request.setHeader('Content-Type', 'application/xhtml+xml; charset=UTF-8') # now go and write the Output # request.finish() is called inside webif.py (requestFinish() which is called via renderPage()) webif.renderPage(request, path, self.session) # login? request.setResponseCode(http.OK) elif os_path.isdir(path) and self.addSlash is True: uri = "%s/" % (request.path) request.redirect(uri) return ""; else: return resource.ErrorPage(http.NOT_FOUND, "Page Not Found", "Sorry, but the page you were trying to view does not exist.").render(request); return server.NOT_DONE_YET
def render(self, request): path = self.path if os_path.isfile(path): lastComponent = path.split('/')[-1] # Set the Header according to what's requested if lastComponent in AppTextHeaderFiles: request.setHeader('Content-Type', 'application/text') elif lastComponent in TextHtmlHeaderFiles or ( path.endswith(".html.xml") and lastComponent != "updates.html.xml"): request.setHeader('Content-Type', 'text/html; charset=UTF-8') elif lastComponent in TextJavascriptHeaderFiles: request.setHeader('Content-Type', 'text/javascript; charset=UTF-8') elif lastComponent not in NoExplicitHeaderFiles: request.setHeader('Content-Type', 'application/xhtml+xml; charset=UTF-8') # now go and write the Output # request.finish() is called inside webif.py (requestFinish() which is called via renderPage()) webif.renderPage(request, path, self.session) # login? request.setResponseCode(http.OK) elif os_path.isdir(path) and self.addSlash is True: uri = "%s/" % (request.path) request.redirect(uri) return "" else: return resource.ErrorPage( http.NOT_FOUND, "Error 404 - Page not found", "The requested resource is not available").render(request) return server.NOT_DONE_YET