Last active
September 24, 2023 20:54
-
-
Save GabeBenjamin/37da77ee3c63fe3434ceb6ecb7b73231 to your computer and use it in GitHub Desktop.
Simple python server to run HTML5 Godot 4.0+ games locally
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
#!/usr/bin/env python3 | |
""" | |
If you run into the errors for "Cross Origin Isolation" and | |
"SharedArrayBuffer" when trying to run your exported HTML Godot | |
game, use this simple server to fix the problem! | |
Create this file in the same folder as your exported HTML files | |
and run with `python ./server.py`. Then open a web browser | |
and go to localhost:8000 | |
""" | |
from http.server import HTTPServer, SimpleHTTPRequestHandler, test | |
import sys | |
class CORSRequestHandler (SimpleHTTPRequestHandler): | |
def end_headers (self): | |
self.send_header("Cross-Origin-Opener-Policy", "same-origin") | |
self.send_header("Cross-Origin-Embedder-Policy", "require-corp") | |
SimpleHTTPRequestHandler.end_headers(self) | |
if __name__ == '__main__': | |
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment