<commit_before>var express = require('express');
var fs = require('fs');
var url = require('url');
var app = express.createServer();

app.use(express.static(__dirname + '/public'));
app.get('*', handleAnyRequest);
app.post('*', handleAnyRequest);
app.delete('*', handleAnyRequest);
app.put('*', handleAnyRequest);


var TEMPLATE_PATTERN = new RegExp(/{{.*}}/g);

function handleAnyRequest(req, res){
  reqUrl = url.parse(req.url);
  var file = 'json' + reqUrl.pathname + '_' + req.method.toLowerCase() + ".json";
  console.log('Request: ' + file);

  var data = readFileJson(file);
  res.send(data)
}

function readFileJson(file) {
  var data = fs.readFileSync(file, 'utf8');

  data = data.replace(TEMPLATE_PATTERN, function(match) {
    var templateFile = 'json/_templates/' + match.slice(2,-2) + ".json";<commit_msg>added TODOs<commit_after>var express = require('express');
var fs = require('fs');
var url = require('url');
var app = express.createServer();

app.use(express.static(__dirname + '/public'));
app.get('*', handleAnyRequest);
app.post('*', handleAnyRequest);
app.delete('*', handleAnyRequest);
app.put('*', handleAnyRequest);


var TEMPLATE_PATTERN = new RegExp(/{{.*}}/g);

function handleAnyRequest(req, res){
  reqUrl = url.parse(req.url);
  var file = 'json' + reqUrl.pathname + '_' + req.method.toLowerCase() + ".json";
  console.log('Request: ' + file);

  // TODO allow proxying calls to real API (for calls that are already implemented)
  var data = readFileJson(file);
  res.send(data)
}

function readFileJson(file) {
  var data = fs.readFileSync(file, 'utf8');

  data = data.replace(TEMPLATE_PATTERN, function(match) {
    // TODO: allow variables instead of templates like SERVER_BASE_URL
    var templateFile = 'json/_templates/' + match.slice(2,-2) + ".json";
{'fraction_non_alphanumeric': 0.18146286990508095, 'fraction_numerical': 0.0033500837520938024, 'mean_word_length': 5.033670033670034, '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': '5403919', 'n_tokens_mistral': 602, 'n_tokens_neox': 590, 'n_words': 135}