Files
mimaki/webui/README.md
Lukas Cremer cd846577a4 add webui
2026-02-03 22:41:29 +01:00

66 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HPGL Plotter Web UI
Flask web interface for uploading HPGL files, previewing and transforming them (flip, rotate, scale, center), and sending to the plotter. Intended to run on a Raspberry Pi connected to the plotter via USB.
## Setup (Raspberry Pi)
1. From the **project root** (mimaki/), install dependencies:
If you get **externally-managed-environment** (Python 3.11+ / PEP 668) and dont want a venv, use:
```bash
pip install --break-system-packages -r webui/requirements.txt
```
Otherwise:
```bash
pip install -r webui/requirements.txt
```
Optional use a venv to avoid touching system Python:
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r webui/requirements.txt
```
2. **Config:** Copy `config.example.ini` to `config.ini` and adjust (port, baudrate, web UI host/port, etc.). `config.ini` is gitignored.
```bash
cp config.example.ini config.ini
```
Edit `config.ini` to set the plotter port (e.g. `/dev/ttyUSB0`) and optionally web UI port/host.
## Run
From the **project root** (mimaki/):
```bash
python webui/app.py
```
Then open http://<raspi-ip>:5000 in a browser (e.g. http://192.168.1.10:5000).
- **Host:** `0.0.0.0` so other devices on the network can connect.
- **Port:** 5000 (override with `PORT=8080 python webui/app.py` if needed).
For production, run behind gunicorn and optionally a reverse proxy:
```bash
pip install --break-system-packages gunicorn # or omit if not using system Python
gunicorn -w 1 -b 0.0.0.0:5000 "webui.app:app"
```
## Usage
1. **Upload** Choose an `.hpgl` or `.plt` file. It is validated and stored in `webui/uploads/`.
2. **Preview** The drawing is converted to SVG and shown in the browser.
3. **Transform** Flip, Rotate 90° / 180°, Scale + / , Center. Each action updates the stored program and the preview.
4. **Print** Sends the current (transformed) program to the plotter: scale to fit, center, then write HPGL to serial.
## API
- `POST /api/upload` Upload HPGL file (form field `file`).
- `GET /api/svg` Get current program as SVG (query: `width`, `height`).
- `POST /api/transform` Body: `{"action": "flip"|"rotate"|"scale"|"centralize", "angle": 90, "factor": 1.25}`.
- `POST /api/print` Send current program to plotter.
- `GET /api/status` `has_file`, `filename`, `plotter_ready`.
Session is used to keep the current file path; no database.