Skip to content

Instantly share code, notes, and snippets.

@s-chb
Created July 15, 2020 08:03
Show Gist options
  • Save s-chb/cf7dc7f24315d7081da6120454cd1ade to your computer and use it in GitHub Desktop.
Save s-chb/cf7dc7f24315d7081da6120454cd1ade to your computer and use it in GitHub Desktop.
const http = require('http');
http.createServer(function (req, res) {
console.log('..' + req.method + ' method invoked');
if (req.method === 'POST') {
let body = '';
req.on('data', chunk => {
body += chunk.toString();
});
req.on('end', () => {
console.log('..' + body);
res.end('ok');
});
}
else {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Please, send a post request');
res.end();
}
}).listen(8888);
console.log('..Listener http serving by port 8888');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment