bibimbap/.atp/work-session/20261014-091658/artifacts/input-supplemental/server.py

15 lines
1.5 KiB
Python

from http.server import HTTPServer,SimpleHTTPRequestHandler
from pathlib import Path
root=Path('/Users/wemadeplay/workspace/stz/bibimbap')
game=Path('/tmp/bibimbap-inv004-uploads/game/d4bf0e5b-5582-49f7-862d-be47e99092b2/GoraniCoin-WebGLTest')
class H(SimpleHTTPRequestHandler):
def do_GET(self):
if self.path=='/':
b=b'''<!doctype html><meta charset="utf-8"><link rel="stylesheet" href="/css/webgl-player.css"><style>body{margin:0;padding:16px;box-sizing:border-box}</style><div class="webgl-player" data-webgl-player data-display-width="390" data-display-height="844" style="--game-ratio:0.4620853"><div class="webgl-player__toolbar"><button class="webgl-player__button" data-player-expand aria-expanded="false">Expand</button><button class="webgl-player__button" data-player-fullscreen aria-pressed="false">Fullscreen</button><span class="webgl-player__status" data-player-status role="status"></span></div><div class="webgl-player__stage" data-player-stage id="webgl-stage"><iframe src="/game/index.html" sandbox="allow-scripts allow-same-origin allow-pointer-lock" allow="fullscreen; autoplay; xr-spatial-tracking"></iframe></div></div><script src="/js/webgl-player.js"></script>'''
self.send_response(200);self.send_header('Content-Type','text/html');self.end_headers();self.wfile.write(b);return
super().do_GET()
def translate_path(self,p):
if p.startswith('/game/'):return str(game/p[6:])
return str(root/'src/main/webapp'/p.lstrip('/'))
HTTPServer(('127.0.0.1',18086),H).serve_forever()