Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import http.server
- import socketserver
- class UnityRequestHandler(http.server.SimpleHTTPRequestHandler):
- def end_headers(self):
- # Allow Cross-Origin Isolation (needed for many Unity games)
- self.send_header("Cross-Origin-Opener-Policy", "same-origin")
- self.send_header("Cross-Origin-Embedder-Policy", "require-corp")
- # Tell the browser to decompress Brotli (.br) files
- if self.path.endswith('.br'):
- self.send_header('Content-Encoding', 'br')
- # Set correct MIME types for compressed files
- if self.path.endswith('.js.br'):
- self.send_header('Content-Type', 'application/javascript')
- elif self.path.endswith('.wasm.br'):
- self.send_header('Content-Type', 'application/wasm')
- elif self.path.endswith('.data.br'):
- self.send_header('Content-Type', 'application/octet-stream')
- super().end_headers()
- PORT = 8000
- with socketserver.TCPServer(("", PORT), UnityRequestHandler) as httpd:
- print(f"Server started at http://localhost:{PORT}")
- httpd.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment