diff --git a/door_open.html b/door_open.html index f08a213810ac66e65b534ac739ff3e581ab6e120..7ee6ed64345975e07d1af1f6c933a1b45f3d496d 100644 --- a/door_open.html +++ b/door_open.html @@ -6,6 +6,7 @@ <body> <h1>UCC Door Status</h1> <p>The door is currently open!</p> + <p>Opened by: <span id="opener">a mysterious entity</span></p> <img src="/gary.jpg" width="574" @@ -13,6 +14,15 @@ alt="A wild Gary lurking in the open doorway to the UCC clubroom." title="A wild Gary lurking in the open doorway to the UCC clubroom." ></img> + <script async> + fetch('/opener').then(response => { + response.json().then(opener => { + if (opener) { + document.getElementById('opener').innerText = opener; + } + }); + }); + </script> </body> </html> diff --git a/main.js b/main.js index 8cb769adb9494a2227dadc21ae25fa57445fc401..b26ede4e8be170ac1188638d07fc55b12b0c0e4b 100644 --- a/main.js +++ b/main.js @@ -105,7 +105,7 @@ const server = http.createServer((req, res) => { return send_json(res, 500, null); } - return send_json(res, 200, doorOpener); + return send_json(res, 200, doorState ? doorOpener : null); } if (req.url === '/gary.jpg') {