Simple HTTP server, listening on localhost:8083 which just echoes back HTTP requets sent to it.
Blantant ripoff of: https://gist.github.com/bszwej/62c327d773051816ed4949fd40c82c74
Simple HTTP server, listening on localhost:8083 which just echoes back HTTP requets sent to it.
Blantant ripoff of: https://gist.github.com/bszwej/62c327d773051816ed4949fd40c82c74
| import http from 'node:http'; | |
| const server = http.createServer(); | |
| server.on('request',(req,resp) => { | |
| const body = []; | |
| req.on('data',function(chunk) { | |
| body.push(chunk); | |
| }); | |
| req.on('end',function() { | |
| console.log(`>> Request: ${req.method} ${req.url}`); | |
| console.log('>> HTTP headers'); | |
| console.log(req.headers); | |
| console.log('>> Body'); | |
| console.log(Buffer.concat(body).toString()); | |
| console.log('\n'); | |
| resp.end(); | |
| }); | |
| }).listen(8083); |
| { | |
| "type": "module" | |
| } |