1
0
mirror of https://api.glitch.com/git/presence-button synced 2024-11-05 10:57:30 +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