forked from kaischallenberg/monstercatVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (24 loc) · 788 Bytes
/
server.js
File metadata and controls
29 lines (24 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const express = require('express');
const app = express();
const port = 3000;
const path = require('path');
// Middleware to parse JSON bodies
app.use(express.json());
// Serve static files from the current directory
app.use(express.static(__dirname));
// Endpoint to receive logs from the client
app.post('/log', (req, res) => {
const { message } = req.body;
if (message) {
// Clear line and log to keep it clean, or just log normally
console.log(`\x1b[36m[Now Playing]\x1b[0m ${message}`);
}
res.sendStatus(200);
});
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
console.log('Press Ctrl+C to stop the server.');
});