-
Notifications
You must be signed in to change notification settings - Fork 303
Expand file tree
/
Copy pathserver.py
More file actions
27 lines (23 loc) · 794 Bytes
/
server.py
File metadata and controls
27 lines (23 loc) · 794 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
"""
Simple HTTP server with proper WASM MIME type support
Run: python3 server.py
Access: http://127.0.0.1:8000
"""
import http.server
import socketserver
import os
PORT = 8000
class WasmHandler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
# Set proper MIME type for .wasm files
if self.path.endswith('.wasm'):
self.send_header('Content-Type', 'application/wasm')
super().end_headers()
if __name__ == "__main__":
os.chdir(os.path.dirname(os.path.abspath(__file__)))
with socketserver.TCPServer(("", PORT), WasmHandler) as httpd:
print(f"Server running at http://127.0.0.1:{PORT}")
print(f"Serving from: {os.getcwd()}")
print("Press Ctrl+C to stop")
httpd.serve_forever()