Skip to content

Instantly share code, notes, and snippets.

@jcrugzz
Created May 19, 2016 20:11
Show Gist options
  • Save jcrugzz/c9794c8b65722ba2fbb168b1e7851803 to your computer and use it in GitHub Desktop.
Save jcrugzz/c9794c8b65722ba2fbb168b1e7851803 to your computer and use it in GitHub Desktop.
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