Webvm2 / run.sh
memex-in's picture
Create run.sh
0da2a12 verified
raw
history blame
901 Bytes
#!/bin/bash
# This script starts a Python HTTP server with custom headers
# required for SharedArrayBuffer (COEP and COOP).
# Create a temporary Python server script
cat <<EOF > server.py
import http.server
import socketserver
PORT = 8000
class Handler(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
# Add the required Cross-Origin-Embedder-Policy header
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp')
# Add the required Cross-Origin-Opener-Policy header
self.send_header('Cross-Origin-Opener-Policy', 'same-origin')
super().end_headers() # Call the original end_headers to send other headers
# Start the server
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving real_webvm.html at http://localhost:{PORT}")
httpd.serve_forever()
EOF
# Execute the Python server script
python server.py