Created
March 17, 2022 00:27
-
-
Save jerrans/88e0d46549035ed5c406e26e04d8544d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Python 3 | |
import sys | |
import socketserver | |
from http.server import SimpleHTTPRequestHandler | |
class WasmHandler(SimpleHTTPRequestHandler): | |
def end_headers(self): | |
self.send_header("Cross-Origin-Opener-Policy", "same-origin") | |
self.send_header("Cross-Origin-Embedder-Policy", "require-corp") | |
SimpleHTTPRequestHandler.end_headers(self) | |
# Python 3.7.5 adds in the WebAssembly Media Type. If this is an older | |
# version, add in the Media Type. | |
if sys.version_info < (3, 7, 5): | |
WasmHandler.extensions_map['.wasm'] = 'application/wasm' | |
if __name__ == '__main__': | |
PORT = 8080 | |
with socketserver.TCPServer(("", PORT), WasmHandler) as httpd: | |
print("Listening on port {}. Press Ctrl+C to stop.".format(PORT)) | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment