<commit_before>var path = require('path');
var url = require('url');
var express = require('express');
var config = require('./config');

var useSandbox = false;

// process command line arguments
process.argv.forEach(function(val, index, array) {
  if(val == 'sandbox') {
    useSandbox = true;
  }
});

var joinPath = function(root, path) {
  return root + '/' + path;
}

var resolveFilepath = function(filepath) {
  console.log("filepath is " + filepath);
  // default to index.html
  if (filepath == '/')
    filepath = 'index.html';
  // index.html lives in the client root dir
  if (filepath == 'index.html') {
    if (useSandbox)
      return joinPath(config.getSandboxPath(), filepath);
    else
      return joinPath(config.getClientPath(), filepath);
  }
  // other assets live under the 'content' subdirectory
  else {
    if (useSandbox)
      return joinPath(config.getSandboxContentPath(), filepath);
    else
      return config.getContentPath() + '/' + filepath;
  }
}

var app = express();
app.get('/', function(req, res) {
  filepath = resolveFilepath(url.parse(req.url).pathname);
  console.log('GET ' + filepath);
  res.sendfile(path.resolve(filepath));
});

// spin up the server
var port = 1337;
app.listen(port);
console.log("Sweet\nhttp://localhost:" + port + "\nCTRL + C to stop");
if (useSandbox) {
  console.log("[SANDBOX]");
}<commit_msg>[server] HTTP requests work again<commit_after>var path = require('path');
var url = require('url');
var express = require('express');
var config = require('./config');

var useSandbox = false;

// process command line arguments
process.argv.forEach(function(val, index, array) {
  if(val == 'sandbox') {
    useSandbox = true;
  }
});

var joinPath = function(root, path) {
  return root + '/' + path;
}

var resolveFilepath = function(filepath) {
  console.log("filepath is " + filepath);
  // default to index.html
  if (filepath == '/')
    filepath = 'index.html';
  // index.html lives in the client root dir
  if (filepath == 'index.html') {
    if (useSandbox)
      return joinPath(config.getSandboxPath(), filepath);
    else
      return joinPath(config.getClientPath(), filepath);
  }
  // other assets live under the 'content' subdirectory
  else {
    if (useSandbox)
      return joinPath(config.getSandboxContentPath(), filepath);
    else
      return config.getContentPath() + '/' + filepath;
  }
}

var app = express();
app.get('/*', function(req, res) {
  filepath = resolveFilepath(url.parse(req.url).pathname);
  console.log('GET ' + filepath);
  res.sendfile(path.resolve(filepath));
});

// spin up the server
var port = 1337;
app.listen(port);
console.log("Sweet\nhttp://localhost:" + port + "\nCTRL + C to stop");
if (useSandbox) {
  console.log("[SANDBOX]");
}
{'fraction_non_alphanumeric': 0.16236832546313112, 'fraction_numerical': 0.002905920813657828, 'mean_word_length': 3.7729636048526864, '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': '462528', 'n_tokens_mistral': 922, 'n_tokens_neox': 893, 'n_words': 224}