Skip to content

Instantly share code, notes, and snippets.

@djedi
Created May 24, 2016 19:22
Show Gist options
  • Save djedi/99cdb0ded584aca9b2a0bf1c3aa86c86 to your computer and use it in GitHub Desktop.
Save djedi/99cdb0ded584aca9b2a0bf1c3aa86c86 to your computer and use it in GitHub Desktop.
var http = require('http');
http.createServer(
function (req, res) {
var body = [];
req.on('error', function(err) {
console.error('error', err);
}).on('data', function(chunk) {
body.push(chunk);
}).on('end', function() {
body = Buffer.concat(body).toString();
console.log(body);
});
res.writeHead(200, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*'
});
res.end('Zzzz...\n');
}
).listen(3000, '0.0.0.0');
console.log('Server running at http://127.0.0.1:3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment