Since we can assume everyone's on Python 3 by now, the example by @berto in https://stackoverflow.com/a/13354482 can now be considerably shorter:
#!/usr/bin/env python3
from http import server
class MyHTTPRequestHandler(server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header("Access-Control-Allow-Origin", "*")
super().end_headers()
server.test(HandlerClass = MyHTTPRequestHandler)
(Note: I was trying to post this as a comment, but you can't have code blocks in comments?)