bookquoy/serve.py
type-two 7afae85599 park_kit dressing: textured figs, furniture, fence line + /kit/ mount
serve.py mounts the sibling park_kit repo at /kit/ (PARK_KIT env to
repoint) — same convention as skatemakerpro, so editor-exported levels
work unchanged. level.js PROPS lists the dressing (island Moreton Bays,
gums, benches, bin, picnic table, bleachers, shade sail, fence sections,
floodlights, hydrant, graffiti wall); main.js loads them onto heightAt.
Procedural cone-figs retired.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 21:15:19 +10:00

34 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""BOOKQUOY dev server — http.server with caching disabled so module edits show up.
Also mounts the park_kit sibling repo at /kit/ (textured props + surfaces), same
convention as skatemakerpro: override with PARK_KIT=/path/to/park_kit."""
import http.server, mimetypes, os, sys
ROOT = os.path.dirname(os.path.abspath(__file__))
KIT = os.environ.get('PARK_KIT', os.path.join(os.path.dirname(ROOT), 'park_kit'))
class NoCache(http.server.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Cache-Control', 'no-store, must-revalidate')
super().end_headers()
def do_GET(self):
if self.path.startswith('/kit/'):
rel = os.path.normpath(self.path[5:].split('?')[0]).lstrip('/')
f = os.path.join(KIT, rel)
if f.startswith(KIT + os.sep) and os.path.isfile(f):
ctype = mimetypes.guess_type(f)[0] or 'application/octet-stream'
data = open(f, 'rb').read()
self.send_response(200)
self.send_header('Content-Type', ctype)
self.send_header('Content-Length', str(len(data)))
self.end_headers()
self.wfile.write(data)
else:
self.send_error(404)
return
super().do_GET()
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8141
http.server.ThreadingHTTPServer(('', port), NoCache).serve_forever()