Question : how to respond to options request
Answered by : friendly-finch-9v29msyfjr14
class MyHandler(BaseHTTPRequestHandler): def do_OPTIONS(self): self.send_response(200, "ok") self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS') self.send_header("Access-Control-Allow-Headers", "X-Requested-With") def do_GET(self): self.send_response(200) self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write("<html><body>Hello world!</body></html>") self.connection.shutdown(1)
Source : https://stackoverflow.com/questions/2580461/how-to-respond-to-http-options-request-on-a-json-rpc-server | Last Update : Fri, 12 Jun 20