-
Notifications
You must be signed in to change notification settings - Fork 1
API Reference
This document describes the HTTP APIs exposed by the Flask backend (app.py) and how they are used by the web frontend (index.html).
The application provides a local web dashboard for managing the Sinden Lightgun services, configuration, profiles, backups, logs, and software updates.
- Backend: Python 3 + Flask
- Frontend: Single-page HTML/CSS/JavaScript (served statically)
- Transport: JSON over HTTP
- Auth: None (assumes trusted local network / device)
-
Base URL:
http://<host>
All API endpoints are prefixed with /api/ unless otherwise stated.
Simple health check endpoint.
Response
{ "ok": true }These endpoints control and inspect systemd services related to the lightgun.
Returns the current status of managed services.
Response
{
"lightgun.service": "active",
"lightgun-monitor.service": "inactive"
}Used by the UI to:
- Display service status
- Drive the online/offline mode indicator
Start, stop, or restart a service.
-
service:
lightgun.service|lightgun-monitor.service -
action:
start|stop|restart
Response
{
"success": true,
"status": "active"
}Returns systemctl status output for the given service.
Response
{ "logs": "<systemd output>" }Reports the currently active platform mode.
- Determined from
/run/lightgun/sinden_mode - Falls back to
ps2if unavailable
Response
{ "ok": true, "platform": "ps2" }Used by the frontend to:
- Switch UI theme (PS1 red / PS2 blue)
- Display the correct mode icon
Performs a system power action via systemctl.
-
action:
reboot|shutdown
Response
{ "ok": true }Note: The response may not be delivered if the system shuts down immediately.
Returns the contents of the Sinden Lightgun runtime log file.
Response
{ "logs": "<log file contents>" }Displayed in the Lightgun Log tab.
These endpoints manage the XML configuration files for PS1 and PS2 modes.
Loads the active or profile configuration.
Query Parameters
-
platform(optional):ps1orps2 -
profile(optional): profile name (loads fromprofiles/instead of live file)
Response
{
"ok": true,
"platform": "ps2",
"path": "/path/to/LightgunMono.exe.config",
"player1": [ { "key": "SerialPort", "value": "..." } ],
"player2": [ { "key": "SerialPort", "value": "..." } ],
"player1Groups": [ { "name": "Device & Ports", "items": [...] } ],
"player2Groups": [ { "name": "Device & Ports", "items": [...] } ],
"source": "live",
"profile": ""
}The grouped data is used to render structured forms in the UI.
Saves configuration changes in-place, strictly preserving XML layout, comments, and order.
Request Body
{
"platform": "ps2",
"player1": [ { "key": "SerialPort", "value": "..." } ],
"player2": [ { "key": "SerialPort", "value": "..." } ]
}Response
{
"ok": true,
"platform": "ps2",
"path": "...",
"backup": ".../backups/LightgunMono.exe.config.TIMESTAMP.bak"
}A byte-for-byte backup is created automatically before changes are applied.
Profiles are stored as full copies of configuration files.
Lists available profiles.
Response
{
"ok": true,
"platform": "ps2",
"profiles": [
{ "name": "default", "path": "...", "mtime": 1700000000 }
]
}Saves the current live configuration as a named profile.
Request Body
{ "platform": "ps2", "name": "myprofile", "overwrite": false }Overwrites the live configuration with the selected profile.
A safety backup of the live file is created automatically.
Deletes a saved profile.
Lists automatic and manual backups.
Response
{
"ok": true,
"platform": "ps2",
"backups": [
{ "name": "LightgunMono.exe.config.20240225-101010.bak", "mtime": 1700000000, "size": 12345 }
]
}Restores a selected backup file to the live configuration.
Request Body
{ "platform": "ps2", "filename": "LightgunMono.exe.config.20240225-101010.bak" }A safety backup of the current live config is created before restore.
These endpoints wrap a privileged update script.
Returns the current update state and installed channel.
Prepares the selected update channel.
Supported channels:
latestpreviousbetapsilocubuntu
Runs the update script for the selected channel.
Request Body
{ "channel": "latest" }Returns update logs (from file or in-memory buffer).
The following paths serve static assets used by the UI:
/logo.png/ps1.png/ps2.png/load.png/offline.png/favicon.ico
- All UI actions use
fetch()with JSON payloads - Polling is used for:
- Service status
- Logs
- Platform/mode detection
- No client-side routing; visibility is controlled by tab switching
- APIs execute privileged system actions (
systemctl, file writes) - Intended for local, trusted environments only
- Should not be exposed directly to untrusted networks
Internal project – SindenPS dashboard tooling.