<commit_before>// Copyright 2016 <NAME>
// $ npm install
// Requires a simple HTTP server running on port 4001 in the label_templates directory
// DOES NOT REQUIRE NODE-CANVAS (YAY)
var dotenv = require('dotenv');
dotenv.load();
var bodyParser = require('body-parser');
var express = require('express');
var fs = require('fs');
var img = require('cropng');
require('shelljs/global');
var app = express();
var port = 3006;
app.use(bodyParser.json({extended: true}));
app.use(bodyParser.urlencoded({extended: true}));
app.use("/", express.static(__dirname + "/label_templates"));
app.use(function(req, res, next) { // enable CORS
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  res.setHeader('Content-Type', 'application/json');
  next();
});

mkdir('label_templates');
// Send search query, receive awesomeness back
app.post('/nutritionize', function (req, res) {
  if (req.body.query) {
        var searchQuery = req.body.query;
        var netResult = exec('phantomjs --web-security=no --ssl-protocol=any --ignore-ssl-errors=yes deps/nutritionize-net.js "'+ searchQuery +'"', {silent:true}).output;

        var uuid = generatePushID();
        fs.writeFile(__dirname + "/label_templates/"+uuid+".json", netResult, function (err) {
          if (err) throw err;
          fs.readFile("deps/label.html", "utf-8", function (e, d) {
            if (e) throw e;
            fs.writeFile("label_templates/"+uuid+".html", d, function (error) {
              if (error) throw error;
              console.log("Successfully created template: " + uuid);
              console.log(process.env.HOSTNAME+"/"+uuid+".html");
              var photo = JSON.parse(exec('phantomjs deps/camera.js http://localhost:4001/'+uuid+'.html', {silent:false}).output);
<commit_msg>fixes<commit_after>// Copyright 2016 <NAME>
// $ npm install
// Requires a simple HTTP server running on port 4001 in the label_templates directory
// DOES NOT REQUIRE NODE-CANVAS (YAY)
var dotenv = require('dotenv');
dotenv.load();
var bodyParser = require('body-parser');
var express = require('express');
var fs = require('fs');
var img = require('cropng');
require('shelljs/global');
var app = express();
var port = 3006;
app.use(bodyParser.json({extended: true}));
app.use(bodyParser.urlencoded({extended: true}));
app.use("/", express.static(__dirname + "/label_templates"));
app.use(function(req, res, next) { // enable CORS
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  res.setHeader('Content-Type', 'application/json');
  next();
});

mkdir('label_templates');
// Send search query, receive awesomeness back
app.post('/nutritionize', function (req, res) {
  if (req.body.query) {
        var searchQuery = req.body.query;
        var netResult = exec('phantomjs --web-security=no --ssl-protocol=any --ignore-ssl-errors=yes deps/nutritionize-net.js "'+ searchQuery +'"', {silent:false}).output;

        var uuid = generatePushID();
        fs.writeFile(__dirname + "/label_templates/"+uuid+".json", netResult, function (err) {
          if (err) throw err;
          fs.readFile("deps/label.html", "utf-8", function (e, d) {
            if (e) throw e;
            fs.writeFile("label_templates/"+uuid+".html", d, function (error) {
              if (error) throw error;
              console.log("Successfully created template: " + uuid);
              console.log(process.env.HOSTNAME+"/"+uuid+".html");
              var photo = JSON.parse(exec('phantomjs deps/camera.js http://localhost:4001/'+uuid+'.html', {silent:false}).output);

{'fraction_non_alphanumeric': 0.175533351336754, 'fraction_numerical': 0.009181744531460978, 'mean_word_length': 3.7184713375796177, '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': '803079', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1137, 'n_words': 266}