Add web interface and Docker deployment

Expose the paste tool through a lightweight web UI/API and provide the container setup required for the publicpaste service.
This commit is contained in:
2026-05-13 01:00:40 +08:00
parent 77e8a76d4e
commit 73a6614118
6 changed files with 424 additions and 0 deletions
+37
View File
@@ -52,6 +52,43 @@ Useful options:
Failures print a concise error to stderr and exit with status `1`.
## Web service
`publicpaste` also includes a zero-dependency web UI and JSON API:
```sh
python -m publicpaste.web
# or, after installation:
publicpaste-web
```
Open `http://127.0.0.1:12072`, enter text, and click “完成”. The page calls `POST /api/paste`, shows the returned URL/provider, and copies the URL to the clipboard.
Useful environment variables:
- `PUBLICPASTE_HOST`: bind host, default `0.0.0.0`
- `PUBLICPASTE_PORT`: bind port, default `12072`
- `PUBLICPASTE_DATA_DIR`: data/log directory, default `/data`
- `PUBLICPASTE_TIMEOUT`: per-provider timeout, default `8.0`
- `PUBLICPASTE_OVERALL_TIMEOUT`: total wait budget, default `12.0`
- `PUBLICPASTE_VERIFY`: verify returned URL when true, default false
Health check:
```sh
curl http://127.0.0.1:12072/health
```
## Docker
Build and run with Compose:
```sh
docker compose up -d --build
```
The included `compose.yml` uses image/container name `publicpaste`, maps `12072:12072`, and stores logs/data in `/vol1/1000/docker/publicpaste/data` mounted at `/data`.
## Python API
```python