diff --git a/score copy.html b/score copy.html new file mode 100644 index 0000000..b55a845 --- /dev/null +++ b/score copy.html @@ -0,0 +1,192 @@ + + + + + + Kid's Scoreboard + + + +

Kid's Scoreboard

+
+ +
+ + 1 + + 2 + + 3 + + 4 + + 5 + + 6 + + 7 + + 8 + + 9 +
+
+
+
+ + +
+ + +
+
Current Stars: 5
+
+ + + + diff --git a/score.html b/score.html new file mode 100644 index 0000000..bebcc33 --- /dev/null +++ b/score.html @@ -0,0 +1,172 @@ + + + + + + Kid's Scoreboard + + + +

Kid's Scoreboard

+
+ +
+ + 1 + + 2 + + 3 + + 4 + + 5 + + 6 + + 7 + + 8 + + 9 +
+
+
+
+ + +
+ + +
+
Current Stars: 5
+
+ + + + diff --git a/server.js b/server.js new file mode 100644 index 0000000..3f37b6f --- /dev/null +++ b/server.js @@ -0,0 +1,40 @@ +const express = require('express'); +const fs = require('fs'); +const path = require('path'); + +const app = express(); +const PORT = 3000; +const DATA_FILE = path.join(__dirname, 'score_data.json'); + +app.use(express.json()); + +// Read current data +app.get('/data', (req, res) => { + fs.readFile(DATA_FILE, 'utf8', (err, data) => { + if (err) { + return res.status(500).json({ error: 'Failed to read data' }); + } + res.json(JSON.parse(data)); + }); +}); + +// Update data +app.post('/update', (req, res) => { + const { currentStarCount, logs } = req.body; + + // Ensure logs do not exceed 100 entries + const updatedLogs = logs.slice(0, 100); + + const newData = { currentStarCount, logs: updatedLogs }; + + fs.writeFile(DATA_FILE, JSON.stringify(newData, null, 2), (err) => { + if (err) { + return res.status(500).json({ error: 'Failed to update data' }); + } + res.json({ success: true }); + }); +}); + +app.listen(PORT, () => { + console.log(`Server running on http://localhost:${PORT}`); +});