-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
19 lines (16 loc) · 813 Bytes
/
server.py
File metadata and controls
19 lines (16 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import http.server
import socketserver
PORT = 5100
class CORSRequestHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
# Allow cross-origin requests (crucial for fetching WASM wheels from GitHub Pages)
self.send_header('Access-Control-Allow-Origin', '*')
# These headers are often required by complex WASM modules to enable SharedArrayBuffer
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
super().end_headers()
if __name__ == '__main__':
with socketserver.TCPServer(("", PORT), CORSRequestHandler) as httpd:
print(f"🚀 Development server running at: http://localhost:{PORT}")
print("Press Ctrl+C to stop.")
httpd.serve_forever()