Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
443 B
2
Indexable
Never
const http = require('http');


function handleRequest(req, res) {
  let callbackResponse = '';

  req.on('data', chunk => {
    callbackResponse += chunk;
  });

  req.on('end', () => {
    console.log('Received data:', callbackResponse);

    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Data received');
  });
}


http.createServer(handleRequest).listen(3000, () => {
  console.log('Server listening on port 3000');
});
Leave a Comment