-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserve.py
More file actions
31 lines (25 loc) · 990 Bytes
/
serve.py
File metadata and controls
31 lines (25 loc) · 990 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
28
29
30
31
#!/usr/bin/env python3
"""
Simple HTTP server for testing the KERI Browser Wallet POC.
"""
import http.server
import socketserver
PORT = 8000
class CORSHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
"""HTTP handler with CORS headers for worker support."""
def end_headers(self):
# Allow cross-origin for workers (needed for some browser configurations)
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
self.send_header('Access-Control-Allow-Origin', '*')
super().end_headers()
def do_OPTIONS(self):
self.send_response(200)
self.end_headers()
if __name__ == '__main__':
with socketserver.TCPServer(("", PORT), CORSHTTPRequestHandler) as httpd:
print(f"Serving at http://localhost:{PORT}")
try:
httpd.serve_forever()
except KeyboardInterrupt:
print("\nServer stopped")