mirror of
https://github.com/kalmarek/SmallHyperbolic
synced 2024-11-09 04:05:27 +01:00
17 lines
599 B
Python
17 lines
599 B
Python
#!/usr/bin/env python3
|
|
# encoding: utf-8
|
|
"""Use instead of `python3 -m http.server` when you need CORS"""
|
|
|
|
from http.server import HTTPServer, SimpleHTTPRequestHandler
|
|
|
|
class CORSRequestHandler(SimpleHTTPRequestHandler):
|
|
def end_headers(self):
|
|
self.send_header('Access-Control-Allow-Origin', '*')
|
|
self.send_header('Access-Control-Allow-Methods', 'GET')
|
|
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
|
|
return super(CORSRequestHandler, self).end_headers()
|
|
|
|
|
|
httpd = HTTPServer(('localhost', 8003), CORSRequestHandler)
|
|
httpd.serve_forever()
|