cat headers.py | python3 -- - 8080
Last active
October 31, 2023 05:51
-
-
Save auycro/609586f21e62175ea89977295dcf34e8 to your computer and use it in GitHub Desktop.
Run http.server with headers (For GoDot's web local test)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment