Last active
April 22, 2020 11:10
-
-
Save HussainArif12/1c8664cb262d0e3569aa00cf98aa7b89 to your computer and use it in GitHub Desktop.
This file contains 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"); | |
const port = 3000 | |
const Server = http.createServer((request, response) => { | |
if (request.method == 'POST') { | |
let buff = '' //buffer variable to save response | |
request.on('data', function (chunk) { | |
buff += chunk; //concat each newline to the buff variable | |
}) | |
request.on('end', function () { | |
console.log('Body' + buff); //print out variable content | |
response.end("Body accepted" ); | |
}) | |
} | |
else { | |
response.writeHead(200, { 'Content-Type': 'text/plain' }) | |
response.end('Hello'); | |
} | |
}) | |
.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment