<commit_before>var fs=require("fs");

/*
  check if exists
  check if is directory
    if is directory
      check if default filename exists
        if exists respond
        else next
    else is file
      respond
*/

/* Static route */
module.exports=function(statpath,def){
  def=def||"/index.html";
  return function(req,res,next){
    var path=statpath+req.url;
//    console.log(JSON.stringify({      url:req.url      ,path:path    }));
    var bin;

    var response=function(path){
      var ext;
      path.replace(/\.[^.]*$/,function(e){
        ext=e;
      });
      var type;
      console.log("extension: "+ext)
      switch (ext){
        case '.css':
          type='text/css';
          break;
        case '.json':
          type='application/json';
          break;
        case '.js':
          type='text/javascript';
          break;
        case '.ico':
        case '.gif':
        case '.png':
          type='image/png'
          break;
        case '.jpeg':
        case '.jpg':
          bin=true;
          type='image/jpeg';
          break;
        case '.html':
          type='text/html';
          break;
        default:
          type='text/plain;charset=utf8';
          break;
      }
      fs.readFile(path,(!bin)?"utf8":null,function(err,data){
        console.log(path);<commit_msg>mime types<commit_after>var fs=require("fs");

/*
  check if exists
  check if is directory
    if is directory
      check if default filename exists
        if exists respond
        else next
    else is file
      respond
*/

/* Static route */
module.exports=function(statpath,def){
  def=def||"/index.html";
  return function(req,res,next){
    var path=statpath+req.url;
//    console.log(JSON.stringify({      url:req.url      ,path:path    }));
    var bin;

    var response=function(path){
      var ext;
      path.replace(/\.[^.]*$/,function(e){
        ext=e;
      });
      var type;
      console.log("extension: "+ext)
      switch (ext){
        case '.ttf':
          type='application/x-font-ttf';
          bin=true;
          break;
        case '.woff':
          type='application/x-font-woff';
          bin=true;
          break;
        case '.css':
          type='text/css';
          break;
        case '.json':
          type='application/json';
          break;
        case '.js':
          type='text/javascript';
          break;
        case '.ico':
          bin=true;
          type='image/x-icon';
          break;
        case '.gif':
          bin=true;
          type='image/gif';
          break;
        case '.png':
          bin=true;
          type='image/png'
          break;
        case '.jpeg':
        case '.jpg':
          bin=true;
          type='image/jpeg';
          break;
        case '.pdf':
          bin=true;
          type='application/pdf';
          break;
        case '.html':
          type='text/html';
          break;
        default:
          type='text/plain;charset=utf8';
          break;
      }
      fs.readFile(path,(!bin)?"utf8":null,function(err,data){
 //       console.log(path);
{'fraction_non_alphanumeric': 0.1457659987071752, 'fraction_numerical': 0.001292824822236587, 'mean_word_length': 1.526530612244898, 'pattern_counts': {'":': 2, '<': 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': '1114775', 'n_tokens_mistral': 926, 'n_tokens_neox': 912, 'n_words': 196}