Created
November 15, 2015 22:51
-
-
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
This file contains hidden or 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
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