Created
July 15, 2020 08:03
-
-
Save s-chb/cf7dc7f24315d7081da6120454cd1ade to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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