<commit_before>#!/usr/bin/env node
"use strict";
const nstatic = require("node-static");
const exec = require('child_process').exec;

const TWOHOURS = 1000*60*60*2;
const WEEK = 1000*60*60*24*7;


var file = new nstatic.Server('html/', {
  headers: {
    "Content-Security-Policy": "default-src 'self'; img-src *;",
    "X-Content-Type-Options": "nosniff",
    "X-XSS-Protection": " 1; mode=block",
    "Strict-Transport-Security": `max-age=${WEEK}; includeSubDomains;`

  }
});

// schedule re-generating screenshots
function schedule() {
  // those exec calls are async
  //  but we simply don't care about the results because yolo
  console.log(new Date(), "Requesting new screenshots.")
  exec('nodejs ./requestNewScreenshots.js');

  // we should ask for the URLs to the new screenshots... in two hours.
  setTimeout(function() {
    console.log(new Date(), "Getting latest screenshot URLs.")
    exec('nodejs ./getLatest.js', (error, stdout, stderr) => {
      if (error) {
        console.error(`exec error: ${error}`);
        return;
      }
  });
  }, TWO_HOURS);

  // running again next week
  setTimeout(schedule, WEEK)
}

// host stuff in html/
const PORT = process.env.PORT || 4000;
require ('http').createServer(function (req, res) {
  req.addListener('end', function () {
    file.serve(req, res);
  }).resume();
}).listen(PORT);

console.log("> node-static is listening on http://127.0.0.1:"+PORT);<commit_msg>...and hsts max-age is in seconds. also: adding XFO<commit_after>#!/usr/bin/env node
"use strict";
const nstatic = require("node-static");
const exec = require('child_process').exec;

const TWOHOURS = 1000*60*60*2;
const WEEK_SEC = 60*60*24*7;
const WEEK_MS = 1000*WEEK_SEC

var file = new nstatic.Server('html/', {
  headers: {
    "Content-Security-Policy": "default-src 'self'; img-src *;",
    "X-Content-Type-Options": "nosniff",
    "X-XSS-Protection": " 1; mode=block",
    "Strict-Transport-Security": `max-age=${WEEK_SEC}; includeSubDomains;`,
    "X-Frame-Options": "DENY"

  }
});

// schedule re-generating screenshots
function schedule() {
  // those exec calls are async
  //  but we simply don't care about the results because yolo
  console.log(new Date(), "Requesting new screenshots.")
  exec('nodejs ./requestNewScreenshots.js');

  // we should ask for the URLs to the new screenshots... in two hours.
  setTimeout(function() {
    console.log(new Date(), "Getting latest screenshot URLs.")
    exec('nodejs ./getLatest.js', (error, stdout, stderr) => {
      if (error) {
        console.error(`exec error: ${error}`);
        return;
      }
  });
  }, TWO_HOURS);

  // running again next week
  setTimeout(schedule, WEEK_MS)
}

// host stuff in html/
const PORT = process.env.PORT || 4000;
require ('http').createServer(function (req, res) {
  req.addListener('end', function () {
    file.serve(req, res);
  }).resume();
}).listen(PORT);

console.log("> node-static is listening on http://127.0.0.1:"+PORT);
{'fraction_non_alphanumeric': 0.17195945945945945, 'fraction_numerical': 0.020945945945945947, 'mean_word_length': 3.6193447737909517, 'pattern_counts': {'":': 9, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7399518', 'n_tokens_mistral': 1061, 'n_tokens_neox': 983, 'n_words': 256}