Skip to content

Instantly share code, notes, and snippets.

@danielrobertson
Created November 15, 2015 22:51
Show Gist options
  • Save danielrobertson/42e115be516881b1fba9 to your computer and use it in GitHub Desktop.
Save danielrobertson/42e115be516881b1fba9 to your computer and use it in GitHub Desktop.
An HTTP server that accepts a POST request, then returns the contents of the POST request uppercased
var http = require('http');
var map = require('through2-map');
var port = process.argv[2];
var server = http.createServer(function (request, response) {
if (request.method = 'POST') {
request.pipe(map(function (chunk) {
return chunk.toString().toUpperCase();
})).pipe(response);
}
});
server.listen(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment