Add web/ — PTY+WebSocket server, xterm.js PWA client, Dockerfile, and PyInstaller notes
This commit is contained in:
46
web/README.md
Normal file
46
web/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# web/ — Kanjin Web Server & PWA
|
||||
|
||||
## Quick start (Docker)
|
||||
|
||||
From the project root:
|
||||
|
||||
```bash
|
||||
docker build -t kanjin -f web/Dockerfile .
|
||||
docker run -p 8080:8080 kanjin
|
||||
```
|
||||
|
||||
Open http://localhost:8080 in any browser. On Chrome/Edge you can **"Install as app"** via the address bar icon — removes the URL bar and adds a home-screen icon.
|
||||
|
||||
## Windows standalone .exe
|
||||
|
||||
From the project root, with PyInstaller installed:
|
||||
|
||||
```bash
|
||||
pip install pyinstaller
|
||||
pyinstaller --onefile --name Kanjin main.py
|
||||
```
|
||||
|
||||
Deliver `dist/Kanjin.exe` — no Python or dependencies needed on the player's machine.
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
cd web
|
||||
python -m pip install -r requirements.txt
|
||||
python generate_icons.py
|
||||
python server.py # starts uvicorn on :8080 with hot-reload
|
||||
```
|
||||
|
||||
Requires Linux or WSL (uses `pty`). The server spawns `main.py` from the parent directory in a pseudo-terminal and streams it to the browser over WebSocket.
|
||||
|
||||
## File layout
|
||||
|
||||
| Path | Purpose |
|
||||
|---|---|
|
||||
| `server.py` | FastAPI app: serves index.html, mounts /static, handles /ws WebSocket |
|
||||
| `static/index.html` | xterm.js in-browser terminal connected over WebSocket |
|
||||
| `static/manifest.json` | PWA manifest — enables Chrome "Install as app" |
|
||||
| `static/sw.js` | Service worker — precaches the shell for offline launch |
|
||||
| `static/generate_icons.py` | Generates placeholder PNG icons (run once) |
|
||||
| `requirements.txt` | Python deps (fastapi, uvicorn) |
|
||||
| `Dockerfile` | Multi-stage Docker build |
|
||||
Reference in New Issue
Block a user