35 lines
1.3 KiB
Markdown
35 lines
1.3 KiB
Markdown
# Web On The Fly
|
|
|
|
Flask app that streams AI-generated fake websites via SSE.
|
|
|
|
This is a Podman project. Use `podman` instead of `docker` for all container commands.
|
|
|
|
## Commands
|
|
|
|
- `uv run app.py` — start dev server on port 5000
|
|
- `uv run pyright app.py` — typecheck (strict mode in pyproject.toml)
|
|
- `uv run ruff check app.py` — lint
|
|
- `uv run ruff check app.py --fix` — auto-fix lint issues
|
|
|
|
Run lint/typecheck after any code changes.
|
|
|
|
## Architecture
|
|
|
|
- Single file: `app.py`
|
|
- `/` → returns a loading page with spinner + live character counter
|
|
- `/stream` → SSE endpoint; streams LLM output base64-encoded per chunk
|
|
- Client JS buffers chunks in-memory (not localStorage), then replaces the document on `[DONE]`
|
|
|
|
## Env vars (loaded from `.env` via python-dotenv)
|
|
|
|
- `OPENAI_API_KEY` — required
|
|
- `OPENAI_API_URL` — OpenAI-compatible endpoint (default: aipi.reeseapps.com)
|
|
- `MODEL` — model name (default: turbo)
|
|
|
|
## Key details
|
|
|
|
- LLM is called with `stream=True`; chunks are base64-encoded to avoid SSE protocol breaks
|
|
- HTTP timeout is 300s (long generations)
|
|
- Themes defined in `THEMES` list: tuples of `(site_type, description)` (fake_store, fake_wiki, fake_social, etc.)
|
|
- `pyright` is configured in strict mode; use `# noqa: BLE001` for intentional broad exception catches
|