Created
July 3, 2025 12:05
-
-
Save Nolkeg/0ce7b348bd79c8a2fab3b30fb9bf0cd0 to your computer and use it in GitHub Desktop.
Python server to server webgl brotli build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http.server | |
import socketserver | |
import os | |
PORT = 8000 | |
class BrotliHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): | |
def end_headers(self): | |
if self.path.endswith(".br"): | |
self.send_header("Content-Encoding", "br") | |
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() | |
def guess_type(self, path): | |
if path.endswith(".br"): | |
path = path[:-3] | |
return super().guess_type(path) | |
web_dir = os.path.dirname(os.path.abspath(__file__)) | |
os.chdir(web_dir) | |
with socketserver.TCPServer(("", PORT), BrotliHTTPRequestHandler) as httpd: | |
print(f"Serving Unity WebGL Brotli build at http://localhost:{PORT}") | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to