public
Last active

SimpleHTTPServer subclass that sends custom headers

  • Download Gist
serve.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/env python
import SimpleHTTPServer
 
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()
 
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
 
def send_my_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
 
 
if __name__ == '__main__':
SimpleHTTPServer.test(HandlerClass=MyHTTPRequestHandler)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.