Created
May 19, 2016 20:11
-
-
Save jcrugzz/c9794c8b65722ba2fbb168b1e7851803 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 fs = require('fs'); | |
const concat = require('concat-stream'); | |
var server = http.createServer(function (req, res) { | |
console.log(`Received request ${req.url}`); | |
if (req.method === 'POST') { | |
return req.pipe(concat(function (body) { | |
console.log('received data'); | |
console.log(body.toString()); | |
res.end('Received POST request'); | |
})); | |
} | |
res.end('Received request'); | |
}); | |
server.listen(3000, () => { | |
console.log('Listening on port 3000'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment