<commit_before>/***********************************************************************************/
/*
 File:    weathernode.js
 Purpose: Main node file for the weather station qwesta
 Author:  <NAME>, CH-8342 Wernetshausen, www.kusti.ch, 22.9.14
 Github:  https://github.com/ancasicolica/qwesta

 ----------------------------------------------------------------------------------

 This is free and unencumbered software released into the public domain.

 Anyone is free to copy, modify, publish, use, compile, sell, or
 distribute this software, either in source code form or as a compiled
 binary, for any purpose, commercial or non-commercial, and by any
 means.

 In jurisdictions that recognize copyright laws, the author or authors
 of this software dedicate any and all copyright interest in the
 software to the public domain. We make this dedication for the benefit
 of the public at large and to the detriment of our heirs and
 successors. We intend this dedication to be an overt act of
 relinquishment in perpetuity of all present and future rights to this
 software under copyright law.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.

 For more information, please refer to <http://unlicense.org/>

 */
/***********************************************************************************/

var settings = require('./settings');
if (settings.simulator) {
  console.log('QWESTA SIMULATOR ACTIVE');
}
var http = require('http');
var url = require('url');
var path = require('path');
var fs = require('fs');
var weather = require('./weatherrecord.js');

var express = require('express');
var mime = require('mime');

var app = express();
/**
 * Get the file /ajax/current.html
 * This file contains the current records and is generated
 */
app.get('/ajax/current.html', function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end(weather.getNewestRecords());
});

/**
 * Get the file /ajax/temperature.html
 * This file contains the available temperature data and is generated
 */
app.get('/ajax/temperature.html', function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end(weather.getTemperatureDataAsJson());
});

/**
 * Get the file /ajax/humidity.html
 * This file contains the available temperature data and is generated
 */
app.get('/ajax/humidity.html', function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end(weather.getHumidityDataAsJson());
});

/**
 * Get every other file (available in the filesystem)
 */
app.get('*', function (request, response) {

  var uri = url.parse(request.url).pathname;
  var filename = path.join(settings.htmlRootPath, uri);

  fs.exists(filename, function (exists) {
    if (!exists) {
      // File does not exist. Generated files were handled before.
      response.writeHead(404, {'Content-Type': 'text/plain'});
      response.write("Server root: " + process.cwd() + "\n");
      response.write("404 Not Found\n");
      response.end();
      return;
    }

    if (fs.statSync(filename).isDirectory()) {<commit_msg>Debug log for 404 reason<commit_after>/***********************************************************************************/
/*
 File:    weathernode.js
 Purpose: Main node file for the weather station qwesta
 Author:  <NAME>, CH-8342 Wernetshausen, www.kusti.ch, 22.9.14
 Github:  https://github.com/ancasicolica/qwesta

 ----------------------------------------------------------------------------------

 This is free and unencumbered software released into the public domain.

 Anyone is free to copy, modify, publish, use, compile, sell, or
 distribute this software, either in source code form or as a compiled
 binary, for any purpose, commercial or non-commercial, and by any
 means.

 In jurisdictions that recognize copyright laws, the author or authors
 of this software dedicate any and all copyright interest in the
 software to the public domain. We make this dedication for the benefit
 of the public at large and to the detriment of our heirs and
 successors. We intend this dedication to be an overt act of
 relinquishment in perpetuity of all present and future rights to this
 software under copyright law.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.

 For more information, please refer to <http://unlicense.org/>

 */
/***********************************************************************************/

var settings = require('./settings');
if (settings.simulator) {
  console.log('QWESTA SIMULATOR ACTIVE');
}
var http = require('http');
var url = require('url');
var path = require('path');
var fs = require('fs');
var weather = require('./weatherrecord.js');

var express = require('express');
var mime = require('mime');

var app = express();
/**
 * Get the file /ajax/current.html
 * This file contains the current records and is generated
 */
app.get('/ajax/current.html', function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end(weather.getNewestRecords());
});

/**
 * Get the file /ajax/temperature.html
 * This file contains the available temperature data and is generated
 */
app.get('/ajax/temperature.html', function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end(weather.getTemperatureDataAsJson());
});

/**
 * Get the file /ajax/humidity.html
 * This file contains the available temperature data and is generated
 */
app.get('/ajax/humidity.html', function (request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.end(weather.getHumidityDataAsJson());
});

/**
 * Get every other file (available in the filesystem)
 */
app.get('*', function (request, response) {

  var uri = url.parse(request.url).pathname;
  var filename = path.join(settings.htmlRootPath, uri);

  fs.exists(filename, function (exists) {
    if (!exists) {
      // File does not exist. Generated files were handled before.
      response.writeHead(404, {'Content-Type': 'text/plain'});
      response.write("Server root: " + settings.htmlRootPath + "\n");
      response.write("Requested file: " + filename + "\n");
      response.write("404 Not Found\n");
      response.end();
      return;
    }

    if (fs.statSync(filename).isDirectory()) {
{'fraction_non_alphanumeric': 0.17626355061241727, 'fraction_numerical': 0.007180064761368436, 'mean_word_length': 3.885832187070151, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7087687', 'n_tokens_mistral': 1941, 'n_tokens_neox': 1797, 'n_words': 730}