I have this mootools request:
new Request({ url: 'http://localhost:8080/list', method: 'get', }).send();
and a small python server that processes it like this:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import subprocess class HttpHandler(BaseHTTPRequestHandler): def do_GET(self): if self.path == '/list': self.list() else: self._404() def list(self): self.response200() res = "some string" self.wfile.write(res) def _404(self): self.response404() self.wfile.write("404\n") def response200(self): self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Headers', 'X-Request, X-Requested-With') self.send_header('Content-type', 'application/json') self.end_headers() def response404(self): self.send_response(404) self.send_header('Content-type', 'application/json') self.end_headers() def main(): try: server = HTTPServer(('', 8080), HttpHandler) server.serve_forever() except KeyboardInterrupt: server.socket.close() if __name__ == '__main__': main()
When I try to execute this request, I get the following errors:
OPTIONS http://localhost:8080/ 501 (Unsupported method ('OPTIONS')) XMLHttpRequest cannot load http://localhost:8080/. Origin null is not allowed by Access-Control-Allow-Origin.
I'm not sure what is going on. Can someone help me?
source share