<commit_before>var http = require('http')
  , fs   = require('fs')
  , zmq  = require('zmq')
  , PORT = process.argv[2] || 8080
  , HOST = process.argv[3] || '127.0.0.1'
  , sock = zmq.socket('sub');


sock.connect('tcp://127.0.0.1:60000');
sock.subscribe('room');


http.createServer(function (req, res) {
   if (req.url == '/events') {
      res.writeHead(200, { 'Content-Type'  : 'text/event-stream'
                         , 'Cache-Control' : 'no-cache'
                         , 'Connection'    : 'keep-alive'
                         });
      console.log('Client connect');

      var callback = function (data) {
         console.log('Send data');
         res.write('data: '+data.toString()+'\n\n');
      };

      sock.on('message', callback);

      res.socket.on('close', function () {
         sock.removeListener('message', callback);
         console.log('Client leave');
      });

   } else {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write(fs.readFileSync(__dirname + '/templates/index.html'));
      res.end()
   }
}).listen(PORT, HOST);<commit_msg>serve static file async<commit_after>var http       = require('http')
  , fs         = require('fs')
  , zmq        = require('zmq')
  , PORT       = process.argv[2] || 8080
  , HOST       = process.argv[3] || '127.0.0.1'
  , ZMQ_STRING = 'tcp://127.0.0.1:60000'
  , sock       = zmq.socket('sub');


sock.connect(ZMQ_STRING);
sock.subscribe('room');


http.createServer(function (req, res) {
   console.log(new Date().toTimeString()+' -- '+req.method+' '+req.url);

   if (req.url == '/events') {
      res.writeHead(200, { 'Content-Type'  : 'text/event-stream'
                         , 'Cache-Control' : 'no-cache'
                         , 'Connection'    : 'keep-alive'
                         });
      console.log('Client connect');

      var callback = function (data) {
         console.log('Send data');
         res.write('data: '+data.toString()+'\n\n');
      };

      sock.on('message', callback);

      res.socket.on('close', function () {
         sock.removeListener('message', callback);
         console.log('Client leave');
      });

   } else if (req.url == '/') {
      fs.readFile(__dirname+'/templates/index.html', function (err, file) {
         res.writeHead(200, {'Content-Type': 'text/html'});
         res.write(file, 'binary');
         res.end()
      });
   }
}).listen(PORT, HOST);


console.log('Server listening on '+HOST+':'+PORT);
console.log(new Date().toTimeString());
console.log('----------------------------------');
{'fraction_non_alphanumeric': 0.20929324482623976, 'fraction_numerical': 0.022647403358063256, 'mean_word_length': 2.139705882352941, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '3562232', 'n_tokens_mistral': 867, 'n_tokens_neox': 813, 'n_words': 135}