const http = require('http'); function time() { let now = new Date(); return `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, 0)}:${now.getSeconds().toString().padStart(2, 0)}`; } const server = http.createServer((req, res) => { if (req.method != "POST") { res.writeHead(400); return; } let data = ""; req.on('data', chunk => { data += chunk; }) req.on('end', () => { console.log(`[${time()}]${data}`); res.writeHead(200); res.end(); }) }); console.log("Listening on port 8080") server.listen(8080);