Skip to content

Instantly share code, notes, and snippets.

@robertklep
Created May 16, 2013 18:54
Show Gist options
  • Save robertklep/5594121 to your computer and use it in GitHub Desktop.
Save robertklep/5594121 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn;
var express = require('express');
var app = express();
app.use(express.static(__dirname));
app.get('/colorsRequest', function(req, res) {
var command = spawn('./run.sh', [ req.query.color || '' ]);
var output = [];
command.stdout.on('data', function(chunk) {
output.push(chunk);
});
command.on('close', function(code) {
if (code === 0)
res.send(Buffer.concat(output));
else
res.send(500);
});
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment