KPRSpaceAPI/README.md

30 lines
1.1 KiB
Markdown
Raw Normal View History

2023-12-02 22:03:06 +00:00
# KPRSpaceAPI
2025-10-20 05:02:59 +00:00
Implementation of the Space API used in KPR, based on a simple webcam running through Motion which detects whether the light is turned on and updates the status of the space accordingly.
## Run (fish shell)
Create and activate a virtual environment, install dependencies and run the server (example using fish):
```fish
python3 -m venv venv
source venv/bin/activate.fish
pip install -r requirements.txt
# Configure environment (examples)
set -x SNAPSHOT_INTERVAL 600 # seconds (600 = 10 minutes)
set -x BRIGHTNESS_THRESHOLD 100 # 0-255
set -x AUTO_START false # true to auto-start on process launch
# Run the app
python app.py
```
Notes
- Screenshots are saved to `./screenshots` by default. Override with `MOTION_DIR`.
- To start/stop the monitor at runtime:
- Start: `curl -X POST http://localhost:5000/api/start`
- Stop: `curl -X POST http://localhost:5000/api/stop`
- The `SNAPSHOT_INTERVAL` env var is interpreted in seconds.
- If you want the server to auto-start the monitor on launch, set `AUTO_START=true` before launching.
- For production use, run under a WSGI server (gunicorn, systemd unit, docker, etc.).