Home-screen web app; phone layout; reload on deploy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-18 14:31:41 +01:00
parent 9058039eb7
commit 14b4c07208
8 changed files with 121 additions and 25 deletions

16
app.py
View file

@ -4,6 +4,7 @@
from __future__ import annotations
import argparse
import hashlib
import json
import logging
import mimetypes
@ -27,6 +28,19 @@ MAX_BODY = 16 * 1024
NAME = re.compile(r"^[\w .'-]{2,20}$")
TICK_SECONDS = 15
def build_version() -> str:
"""Changes whenever the code or client does; open tabs reload when it does."""
digest = hashlib.sha256()
for path in sorted([APP_DIR / "app.py", APP_DIR / "game.py", *STATIC_DIR.rglob("*")]):
if path.is_file():
digest.update(path.name.encode())
digest.update(path.read_bytes())
return digest.hexdigest()[:12]
VERSION = build_version()
mimetypes.add_type("application/manifest+json", ".webmanifest")
@ -360,7 +374,7 @@ class Handler(BaseHTTPRequestHandler):
for e in reversed(world["events"]) if e["status"] == "done"
][:10]
return {
"now": now, "dev": self.dev, "uid": uid,
"now": now, "dev": self.dev, "uid": uid, "version": VERSION,
"me": player_view(world, player, now) if player else None,
"summary": summary,
"city": city_view(world, now),