mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-22 13:37:29 +00:00
🏇👀 Checkpoint
./server.js:933874/3654
This commit is contained in:
parent
e32d24d4d9
commit
6933c9b383
@ -10,7 +10,6 @@ try {
|
|||||||
lastSeen = new Date(JSON.parse(content)["lastSeen"]);
|
lastSeen = new Date(JSON.parse(content)["lastSeen"]);
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
console.log(JSON.stringify({ fuzIsOpen, lastSeen }));
|
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@ -25,13 +24,11 @@ app.get("/", (req, res) => {
|
|||||||
// http://expressjs.com/en/starter/basic-routing.html
|
// http://expressjs.com/en/starter/basic-routing.html
|
||||||
app.get("/img", (req, res) => {
|
app.get("/img", (req, res) => {
|
||||||
res.sendFile(__dirname + "/views/index.html");
|
res.sendFile(__dirname + "/views/index.html");
|
||||||
if (fuzIsOpen && Date() - 5 * 60 * 1000 < lastSeen) {
|
if (fuzIsOpen && Date() - 2 * 60 * 1000 < lastSeen) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.get("/api", (req, res) => {
|
app.get("/api", (req, res) => {
|
||||||
console.log(fuzIsOpen, new Date() - 5 * 1000 < lastSeen)
|
res.send(fuzIsOpen && new Date() - 2 * 60 * 1000 < lastSeen);
|
||||||
res.send(fuzIsOpen && new Date() - 5 * 1000 < lastSeen)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// http://expressjs.com/en/starter/basic-routing.html
|
// http://expressjs.com/en/starter/basic-routing.html
|
||||||
@ -40,7 +37,7 @@ app.get("/status", (req, res) => {
|
|||||||
return res.sendStatus(401);
|
return res.sendStatus(401);
|
||||||
}
|
}
|
||||||
fuzIsOpen = req.query.fuzisopen == "1";
|
fuzIsOpen = req.query.fuzisopen == "1";
|
||||||
lastSeen = Date();
|
lastSeen = new Date();
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen }));
|
fs.writeFileSync(db, JSON.stringify({ fuzIsOpen, lastSeen }));
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user