<commit_before>var app = require("express")();
var pug = require("pug");

var mails = [];
var config;

app.set("views", __dirname + "/views");
app.set("view engine", "pug");

app.get('/', function (req, res) {
  res.type("html");
  res.render('index', { mails: mails });
});

app.get("/emails", function (req, res) {
  res.type("json");
  res.send(JSON.stringify(mails));
});

app.get("/emails/:index(\\d+)", function (req, res, next) {

  var index = +req.params["index"];
  if (index < 0 || index >= mails.length) {
    return next();
  }
  if (mails[index].html === undefined || mails[index].html === null) {
    // plain text mail
    res.type("text");
    // disable mime type sniffing
    res.set('X-Content-Type-Options', 'nosniff');
  } else {
    // html mail
    res.type("html");<commit_msg>Send formatted json on route GET /emails<commit_after>var app = require("express")();
var pug = require("pug");

var mails = [];
var config;

app.set("views", __dirname + "/views");
app.set("view engine", "pug");

app.get('/', function (req, res) {
  res.type("html");
  res.render('index', { mails: mails });
});

app.get("/emails", function (req, res) {
  res.type("json");
  res.send(JSON.stringify(mails, null, 2));
});

app.get("/emails/:index(\\d+)", function (req, res, next) {

  var index = +req.params["index"];
  if (index < 0 || index >= mails.length) {
    return next();
  }
  if (mails[index].html === undefined || mails[index].html === null) {
    // plain text mail
    res.type("text");
    // disable mime type sniffing
    res.set('X-Content-Type-Options', 'nosniff');
  } else {
    // html mail
    res.type("html");
{'fraction_non_alphanumeric': 0.2274390243902439, 'fraction_numerical': 0.001829268292682927, 'mean_word_length': 3.558333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1301089', 'n_tokens_mistral': 587, 'n_tokens_neox': 578, 'n_words': 135}