status web

This commit is contained in:
sebseb7
2020-10-20 07:23:24 +01:00
parent 20698dde53
commit 4a5708e1eb
2 changed files with 27 additions and 1 deletions

View File

@@ -1,4 +1,6 @@
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm i -g pm2
sudo pm2 startup
sudo pm2 startup
npm i express
sudo pm2 start status.js

24
status.js Normal file
View File

@@ -0,0 +1,24 @@
const express = require('express');
const app = express();
const { exec } = require('child_process');
var status = '';
app.get('/', (req, res) => {
res.send('<html><head><title>RPI Speedify Status</title><link rel="icon" href="data:;base64,iVBORw0KGgo="/></head><body>'+status+'</body></html>');
});
setInterval(function(){
exec('/usr/share/speedify/speedify_cli show adapters', (error, stdout, stderr) => {
if (error) {
return;
}
status = stdout;
});
},5000);
app.listen(80);