import http.server
import socketserver
import os
class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
super().end_headers()
def guess_type(self, path):
mimetype = super().guess_type(path)
if path.endswith('.wasm'):
return 'application/wasm'
return mimetype
PORT = 8000
os.chdir(os.path.dirname(os.path.abspath(__file__)))
with socketserver.TCPServer(("", PORT), MyHTTPRequestHandler) as httpd:
print(f"Server running at http://localhost:{PORT}/")
print(f"Open http://localhost:{PORT}/test-wasm.html to test Trek WASM")
httpd.serve_forever()