<commit_before>var spawn = require('child_process').spawn;
var bodyParser = require('body-parser')
var express = require('express');
var app = express();

app.use(bodyParser.json());       

app.post('/', function (req, res) {
  var url = req.body.url;
  var child = spawn('./unoconv', ['--stdout', url]);
  
  child.stderr.on('data', function(data) {
    res.write(data);
    res.status(500).end();
  });

 child.stdout.on('data', function(data) {
    res.write(data);
  });

  child.stdout.on('end', function() {
    res.end();
  });

});

var server = app.listen(process.env.PORT, function () {
  var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});<commit_msg>stream response in data event<commit_after>var spawn = require('child_process').spawn;
var bodyParser = require('body-parser')
var express = require('express');
var app = express();

app.use(bodyParser.json());       

app.post('/', function (req, res) {
  var url = req.body.url;

  console.log(url);

  var child = spawn('./unoconv', ['--stdout', url]);

  child.stderr.on('data', function(data) {
    res.write(data);
    res.status(500).end();
  });

 child.stdout.on('data', function(data) {
    res.write(data);
  });

  child.stdout.on('end', function() {
    res.end();
  });

});

var server = app.listen(process.env.PORT, function () {
  var host = server.address().address;
  var port = server.address().port;
  console.log('Example app listening at http://%s:%s', host, port);
});
{'fraction_non_alphanumeric': 0.20801033591731266, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 3.7956656346749225, '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': '837581', 'n_tokens_mistral': 522, 'n_tokens_neox': 510, 'n_words': 109}