From 95d0e3eb74105a89e8b656f6ede830b5725dc63e Mon Sep 17 00:00:00 2001 From: rosa Date: Wed, 28 Jan 2026 02:56:15 +0100 Subject: [PATCH] feat: add web page with buttons to wake up targets, add /targets endpoint to get all available targets in JSON format --- api.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/api.js b/api.js index 23321f1..02a6990 100644 --- a/api.js +++ b/api.js @@ -8,7 +8,30 @@ const port = 9999; app.use(cors()).use(express.json()); -app.post('/wake', (req, res) => { +app.get("/", (req, res) => { + let html = ` + + + +

Targets:

+ + `; + res.send(html); +}); + +app.get("/targets", (req, res) => { + res.json(Object.keys(targets)); +}); + +app.post("/wake", (req, res) => { const { mac } = req.body; if(!mac) { @@ -23,7 +46,7 @@ app.post('/wake', (req, res) => { }); }); -app.get('/wake', (req, res) => { +app.get("/wake", (req, res) => { const mac = req.query.mac; if(!mac) { @@ -54,10 +77,6 @@ app.get("/wake/:name", (req, res) => { }); }); -app.get("/targets", (req, res) => { - res.json(Object.keys(targets)); -}); - app.listen(port, () => { console.log('WOL server running on port ' + port); }); \ No newline at end of file