9
0
mirror of https://github.com/Lomanic/presence-button-web synced 2024-11-22 13:37:29 +00:00

🌿️ Checkpoint

./server.js:933874/11361
This commit is contained in:
Glitch (hello-express) 2019-11-03 15:01:00 +00:00
parent 271c453ff0
commit f8a56aa613

View File

@ -23,13 +23,19 @@ 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) => {
if (fuzIsOpen && Date() - (2 * 60 * 1000) < lastSeen) { if (fuzIsOpen && new Date() - 2 * 60 * 1000 < lastSeen) {
return res.sendFile(__dirname + "/views/open.svg"); return res.sendFile(__dirname + "/views/open.svg");
} }
res.sendFile(__dirname + "/views/closed.svg"); res.sendFile(__dirname + "/views/closed.svg");
}); });
app.get("/api", (req, res) => { app.get("/api", (req, res) => {
res.send(fuzIsOpen && new Date() - (2 * 60 * 1000) < lastSeen); res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
res.send({ fuzIsOpen, lastSeen
});
}); });
// http://expressjs.com/en/starter/basic-routing.html // http://expressjs.com/en/starter/basic-routing.html