Skip to content

Instantly share code, notes, and snippets.

@auycro
Last active October 31, 2023 05:51
Show Gist options
  • Save auycro/609586f21e62175ea89977295dcf34e8 to your computer and use it in GitHub Desktop.
Save auycro/609586f21e62175ea89977295dcf34e8 to your computer and use it in GitHub Desktop.
Run http.server with headers (For GoDot's web local test)
import sys
from http.server import HTTPServer, SimpleHTTPRequestHandler, test
class CORSRequestHandler (SimpleHTTPRequestHandler):
def end_headers (self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Cross-Origin-Opener-Policy','same-origin')
self.send_header('Cross-Origin-Embedder-Policy','require-corp')
SimpleHTTPRequestHandler.end_headers(self)
if __name__ == '__main__':
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000)

How to use

cat headers.py | python3 -- - 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment