def do_GET_HTTP(self): from platformcode import platformtools from platformcode import controllers # Control de accesos Usuario = "user" Password = "******" ControlAcceso = False import base64 # Comprueba la clave if ControlAcceso and self.headers.getheader( 'Authorization') <> "Basic " + base64.b64encode(Usuario + ":" + Password): self.send_response(401) self.send_header( 'WWW-Authenticate', 'Basic realm=\"Introduce el nombre de usuario y clave para acceder a alfa\"' ) self.send_header('Content-type', 'text/html; charset=utf-8') self.end_headers() self.wfile.write('¡Los datos introducidos no son correctos!') return data = re.compile('/data/([^/]+)/([^/]+)/([^/]+)', re.DOTALL).findall(self.path) if data: data = data[0] if data[0] in platformtools.requests: c = platformtools.requests[data[0]] response = {"id": data[1], "result": data[2]} print response c.handler = self c.set_data(response) while data[ 0] in platformtools.requests and not self.wfile.closed: time.sleep(1) else: if self.path == "": self.path = "/" # Busca el controller para la url controller = controllers.find_controller(self.path) if controller: try: c = controller(self) c.run(self.path) except: if not "socket.py" in traceback.format_exc(): logger.error(traceback.format_exc()) finally: c.__del__() del c return
def do_GET(self): from platformcode import platformtools from platformcode import controllers #Control de accesos Usuario = "user" Password = "******" ControlAcceso = False import base64 #Comprueba la clave if ControlAcceso and self.headers.getheader('Authorization') <> "Basic " + base64.b64encode(Usuario + ":"+ Password): self.send_response(401) self.send_header('WWW-Authenticate', 'Basic realm=\"Introduce el nombre de usuario y clave para acceder a pelisalacarta\"') self.send_header('Content-type', 'text/html; charset=utf-8') self.end_headers() self.wfile.write('¡Los datos introducidos no son correctos!') return data = re.compile('/data/([^/]+)/([^/]+)/([^/]+)', re.DOTALL).findall(self.path) if data: data = data[0] if data[0] in platformtools.requests: c = platformtools.requests[data[0]] response = {"id":data[1],"result": data[2]} print response c.handler = self c.set_data(response) while data[0] in platformtools.requests and not self.wfile.closed: time.sleep(1) else: if self.path =="": self.path="/" #Busca el controller para la url controller = controllers.find_controller(self.path) if controller: try: c = controller(self) c.run(self.path) except: if not "socket.py" in traceback.format_exc(): logger.error(traceback.format_exc()) finally: c.__del__() del c return