<commit_before>// NightScout server file

// NightScout is free software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.

// NightScout is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along with NightScout.
// If not, see <http://www.gnu.org/licenses/>.

// Description: Basic web server to display data from Dexcom G4.  Requires a database that contains
// the Dexcom SGV data.

////////////////////////////////////////////////////////////////////////////////////////////////////
// local variables
////////////////////////////////////////////////////////////////////////////////////////////////////
var patientData = [];
var now = new Date().getTime();
var fs = require('fs');
var c = require("appcache-node");
var mongoClient = require('mongodb').MongoClient;
var pebble = require('./lib/pebble');
var cgmData = [];
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// setup http server
////////////////////////////////////////////////////////////////////////////////////////////////////
var PORT = process.env.PORT || 1337;
var server = require('http').createServer(function serverCreator(request, response) {
    var nodeStatic = require('node-static');
    //enable gzip compression and cache for 30 days
    var staticServer = new nodeStatic.Server(".", { cache:2592000, gzip:true }); 
    var sys = require("sys");
    
    // Grab the URL requested by the client and parse any query options
    var url = require('url').parse(request.url, true);
    if (url.path.indexOf('/pebble') === 0) {
      request.with_collection = with_collection;
      pebble.pebble(request, response);
      return;
    }
    
    // Define the files you want the browser to cache
    var hostname = request.headers.host;
    var cf = c.newCache([
        'http://'+hostname+'/audio/alarm.mp3',
        'http://'+hostname+'/audio/alarm2.mp3',
        'http://'+hostname+'/audio/alarm.mp3.gz',
        'http://'+hostname+'/audio/alarm2.mp3.gz',
        'http://'+hostname+'/css/dropdown.css',
        'http://'+hostname+'/css/main.css',
        'http://'+hostname+'/js/client.js',
        'http://'+hostname+'/js/dropdown.js',
        'http://'+hostname+'/favicon.ico',
        '',
        'NETWORK:',
        '*'
    ]);
    
    // Send the HTML5 nightscout.appcache file
    if(request.url.match(/nightscout\.appcache$/)){
        console.log( 'http://'+hostname+'/nightscout\.appcache')
        response.writeHead(200, {'Content-Type': 'text/cache-manifest'});
        return response.end(cf);
    }

    // Serve file using node-static
    staticServer.serve(request, response, function clientHandler(err) {
        if (err) {
            // Log the error
            sys.error("Error serving " + request.url + " - " + err.message);

            // Respond to the client
            response.writeHead(err.status, err.headers);
            response.end('Error 404 - file not found');
        }
    });
}).listen(PORT);
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// setup socket io for data and message transmission<commit_msg>HTML5 app cache: adding more client libraries<commit_after>// NightScout server file

// NightScout is free software: you can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.

// NightScout is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along with NightScout.
// If not, see <http://www.gnu.org/licenses/>.

// Description: Basic web server to display data from Dexcom G4.  Requires a database that contains
// the Dexcom SGV data.

////////////////////////////////////////////////////////////////////////////////////////////////////
// local variables
////////////////////////////////////////////////////////////////////////////////////////////////////
var patientData = [];
var now = new Date().getTime();
var fs = require('fs');
var c = require("appcache-node");
var mongoClient = require('mongodb').MongoClient;
var pebble = require('./lib/pebble');
var cgmData = [];
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// setup http server
////////////////////////////////////////////////////////////////////////////////////////////////////
var PORT = process.env.PORT || 1337;
var server = require('http').createServer(function serverCreator(request, response) {
    var nodeStatic = require('node-static');
    //enable gzip compression and cache for 30 days
    var staticServer = new nodeStatic.Server(".", { cache:2592000, gzip:true }); 
    var sys = require("sys");
    
    // Grab the URL requested by the client and parse any query options
    var url = require('url').parse(request.url, true);
    if (url.path.indexOf('/pebble') === 0) {
      request.with_collection = with_collection;
      pebble.pebble(request, response);
      return;
    }
    
    // Define the files you want the browser to cache
    var hostname = request.headers.host;
    var cf = c.newCache([
        'http://'+hostname+'/audio/alarm.mp3',
        'http://'+hostname+'/audio/alarm2.mp3',
        'http://'+hostname+'/audio/alarm.mp3.gz',
        'http://'+hostname+'/audio/alarm2.mp3.gz',
        'http://'+hostname+'/css/dropdown.css',
        'http://'+hostname+'/css/main.css',
        'http://'+hostname+'/js/client.js',
        'http://'+hostname+'/js/dropdown.js',
        'http://'+hostname+'/favicon.ico',
        'http://'+hostname+'/socket.io/socket.io.js',
        'http://'+hostname+'/bower_components/d3/d3.min.js',
        'http://'+hostname+'/bower_components/jquery/dist/jquery.min.js',
        'http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,300,400,600,700,800',
        'http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,300italic,400italic,500italic,700italic',
        '',
        'NETWORK:',
        '*'
    ]);
    
    // Send the HTML5 nightscout.appcache file
    if(request.url.match(/nightscout\.appcache$/)){
        console.log( 'http://'+hostname+'/nightscout\.appcache')
        response.writeHead(200, {'Content-Type': 'text/cache-manifest'});
        return response.end(cf);
    }

    // Serve file using node-static
    staticServer.serve(request, response, function clientHandler(err) {
        if (err) {
            // Log the error
            sys.error("Error serving " + request.url + " - " + err.message);

            // Respond to the client
            response.writeHead(err.status, err.headers);
            response.end('Error 404 - file not found');
        }
    });
}).listen(PORT);
////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////
// setup socket io for data and message transmission
{'fraction_non_alphanumeric': 0.29504277805737295, 'fraction_numerical': 0.014091595369904378, 'mean_word_length': 1.5691661279896574, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5024684', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1941, 'n_words': 554}