# devuelvo JS que muestre la excepción: content = """alert("%s");""" % (ex.encode( "ascii", "replace")) else: if ret is None: ret = "OK" # devuelvo JS que llame al callback en el navegador: content = """%s(%s);""" % (callback, repr(ret)) content_type = "application/javascript" print content else: # prueba simple: content_type = "application/javascript" content = """alert("hola mundo %s!");""" % time.time() # envío la respuesta (no cachear y compatibilidad con IE 8): self.send_response(200) self.send_header("Content-type", content_type) self.send_header("X-UA-Compatible", "IE=8") self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") self.send_header("Pragma", "no-cache") self.send_header("Expires", 0) self.end_headers() self.wfile.write(content) # levanto el servidor local: server = HTTPServer(("localhost", 8000), Handler) server.controlador = ControladorFiscal() server.serve_forever()
if isinstance(ex, str): ex = ex.decode("ascii", "replace") # devuelvo JS que muestre la excepción: content = """alert("%s");""" % (ex.encode("ascii", "replace")) else: if ret is None: ret = "OK" # devuelvo JS que llame al callback en el navegador: content = """%s(%s);""" % (callback, repr(ret)) content_type = "application/javascript" print content else: # prueba simple: content_type = "application/javascript" content = """alert("hola mundo %s!");""" % time.time() # envío la respuesta (no cachear y compatibilidad con IE 8): self.send_response(200) self.send_header("Content-type", content_type) self.send_header("X-UA-Compatible", "IE=8") self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") self.send_header("Pragma", "no-cache") self.send_header("Expires", 0) self.end_headers() self.wfile.write(content) # levanto el servidor local: server = HTTPServer(("localhost", 8000), Handler) server.controlador = ControladorFiscal() server.serve_forever()