def do_GET(self): if self.path == "/speedtest": self.speedtest() return elif self.path in ["/", "/index.html"]: SimpleHTTPRequestHandler.do_GET(self) else: SimpleHTTPRequestHandler.send_error(self, 404, "Page not found")
def do_GET(self): if args.directory == None: SimpleHTTPRequestHandler.send_error(self,404) return if self.path[-1:]=="/": SimpleHTTPRequestHandler.send_error(self,404) return SimpleHTTPRequestHandler.do_GET(self)
def do_GET(self): if self.path == "/logs": with open("/opt/tljh/installer.log") as log_file: logs = log_file.read() self.send_response(200) self.send_header("Content-Type", "text/plain; charset=utf-8") self.end_headers() self.wfile.write(logs.encode("utf-8")) elif self.path == "/index.html": self.path = "/var/run/index.html" return SimpleHTTPRequestHandler.do_GET(self) elif self.path == "/favicon.ico": self.path = "/var/run/favicon.ico" return SimpleHTTPRequestHandler.do_GET(self) elif self.path == "/": self.send_response(302) self.send_header("Location", "/index.html") self.end_headers() else: SimpleHTTPRequestHandler.send_error(self, code=403)