Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A web pipe server.
// Run this somewhere with a command you want to pipe stuff through.
// On a machine that needs data processed, run this:
// curl --data-binary @/some/file http://server:port/ > output
var http = require('http');
var spawn = require('child_process').spawn;
// 0 == node, 1 == [this script]
var PORT = parseInt(process.argv[2]);
var CMD = process.argv[3];
if (!CMD) {
console.log("Need a command to run.");
throw("Need a command to run.");
var ARGS = process.argv.slice(4);
function handleReq(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var child = spawn(CMD, ARGS);
http.createServer(handleReq).listen(PORT, "");
console.log('Server running at' + PORT + '/ with ', CMD, ARGS);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.