Skip to content

Instantly share code, notes, and snippets.

@cglewis
Created June 11, 2018 15:44
Show Gist options
  • Save cglewis/5936243c9984f3eae3d82cdfc3afe0d5 to your computer and use it in GitHub Desktop.
Save cglewis/5936243c9984f3eae3d82cdfc3afe0d5 to your computer and use it in GitHub Desktop.
advanced simplehttpserver
#!/usr/bin/env python2
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
self.send_header('Pragma', 'no-cache')
self.send_header('Expires', '0')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
BaseHTTPServer.test(CORSRequestHandler, BaseHTTPServer.HTTPServer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment