<commit_before>var createServer = require('http').createServer,
    parse = require('url').parse,
    createReadStream = require('fs').createReadStream,
    spawn = require('child_process').spawn,
    child = require('event-stream').child;

var port = process.env.PORT || 8000;

function createCmdServer() {
  return createServer(function (req, res) {
    if (req.method == 'POST') {
      var parsedUrl = parse(req.url,true, true),
          args = parsedUrl.query.args,
          cmd = parsedUrl.pathname.replace('/','');
      console.log('Executing',cmd,' with args ', args);
      var proc = child(spawn(cmd, args));
      req.pipe(proc)
         .pipe(res);
    }
    else // GET
      createReadStream('./index.html').pipe(res);
  });
}

createCmdServer().listen(port);
console.log('Server running at http://localhost:'+port+'/');<commit_msg>fixed bug with 1 line argument<commit_after>var createServer = require('http').createServer,
    parse = require('url').parse,
    createReadStream = require('fs').createReadStream,
    spawn = require('child_process').spawn,
    child = require('event-stream').child;

var port = process.env.PORT || 8000;

function createCmdServer() {
  return createServer(function (req, res) {
    if (req.method == 'POST') {
      var parsedUrl = parse(req.url,true, true),
          args = [].concat(parsedUrl.query.args),
          cmd = parsedUrl.pathname.replace('/','');
      console.log('Executing',cmd,' with args ', args);
      var proc = child(spawn(cmd, args));
      req.pipe(proc)
         .pipe(res);
    }
    else // GET
      createReadStream('./index.html').pipe(res);
  });
}

createCmdServer().listen(port);
console.log('Server running at http://localhost:'+port+'/');
{'fraction_non_alphanumeric': 0.17439165701042875, 'fraction_numerical': 0.005214368482039398, 'mean_word_length': 3.4168797953964196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6354065', 'n_tokens_mistral': 527, 'n_tokens_neox': 520, 'n_words': 104}