<commit_before>var fs = require('fs');
var net = require('net');
var path = require('path');
var http2 = require('../lib/index');
var Endpoint = http2.endpoint.Endpoint;

var settings = {
  SETTINGS_MAX_CONCURRENT_STREAMS: 1,
  SETTINGS_INITIAL_WINDOW_SIZE: 100000
};

var server = net.createServer(function(socket) {
  console.error('Incoming connection.');

  var server_endpoint = new Endpoint('SERVER', settings);
  server_endpoint.pipe(socket).pipe(server_endpoint);

  server_endpoint._connection.on('stream', function(stream) {
    console.error('Incoming stream.');

    stream.on('headers', function(headers) {
      var filename = path.join(__dirname, headers[':path']);
      console.error('Incoming request:', headers[':path'], '(' + filename + ')');

      if (fs.existsSync(filename)) {
        console.error('Reading file from disk.');
        stream.headers({
          ':status': '200'
        });
        var filestream = fs.createReadStream(filename);
        filestream.pipe(stream);

      } else {
        console.error('File not found.');
        stream.headers({
          ':status': '404'
        });
        stream.end();
      }
    });
  });
});

var port = 8080;<commit_msg>Example server: updating to use the new public server API.<commit_after>var fs = require('fs');
var net = require('net');
var path = require('path');
var http2 = require('../lib/index');
var Endpoint = http2.endpoint.Endpoint;

var settings = {
  SETTINGS_MAX_CONCURRENT_STREAMS: 1,
  SETTINGS_INITIAL_WINDOW_SIZE: 100000
};

var server = http2.http.createServer({
  plain: true,
  settings: settings
}, function(request, response) {
  var filename = path.join(__dirname, request.url);
  console.error('Incoming request:', request.url, '(' + filename + ')');

  if (fs.existsSync(filename)) {
    console.error('Reading file from disk.');
    response.writeHead('200');
    var filestream = fs.createReadStream(filename);
    filestream.pipe(response);

  } else {
    console.error('File not found.');
    response.writeHead('404');
    response.end();
  }
});

var port = 8080;
{'fraction_non_alphanumeric': 0.15994236311239193, 'fraction_numerical': 0.018731988472622477, 'mean_word_length': 3.6704035874439462, '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': '869711', 'n_tokens_mistral': 665, 'n_tokens_neox': 632, 'n_words': 136}