<commit_before>var fs = require("fs");
var express = require('express');
var bodyParser = require('body-parser');
var md5 = require("md5");
var app = express();

var log4js = require('log4js');
log4js.configure({
    appenders: [
        {type: 'file', filename: 'logs/app.log', maxLogSize: 10485760, backups: 10, category: 'info'}
    ]
});
var logger = log4js.getLogger('info');

//var mongo = require('mongodb');
var db = require('monk')('localhost:27017/leetcode');

app.use(bodyParser.json({limit: '1mb'}));  //body-parser json format
// parse application/x-www-form-urlencoded
// app.use(bodyParser.urlencoded({ extended: false  }))
//app.use(bodyParser.urlencoded({            // this line must follow bodyParser.json
  //extended: true
//}));
// parse application/json
app.use(bodyParser.json());

app.get('/', func_root);
app.get('/leetcode-ext', func_leetcode);
app.get('/leetcode-ext/all_problems', get_all_problems);
app.get('/leetcode-ext/problem/:title', get_problem);
app.post('/leetcode-ext/problem', save_problem);

var server = app.listen(9199, "0.0.0.0", function() {
    var host = server.address().address;
    var port = server.address().port;
});

function func_root(req, res) {
    res.send("There is nothing here~");
}

function func_leetcode(req, res) {
    var data = fs.readFileSync("./leetcode.json", "utf-8");
    res.send(data);
    //res.jsonp(JSON.parse(data));
}

function get_all_problems(req, res) {
    var collection = db.get('problems');
    var data = {};
    collection.find({}, "problem", function(e, docs) {
        for (var i = 0; i < docs.length; ++i) {
            var p = docs[i].problem;
            var title = p.title;
            var companies = docs[i].companies;
            var tags = docs[i].tags;
            if (typeof(companies) == 'undefined' || !companies) companies = [];
            if (typeof(tags) == 'undefined' || !tags) tags = [];<commit_msg>bugfix<commit_after>var fs = require("fs");
var express = require('express');
var bodyParser = require('body-parser');
var md5 = require("md5");
var app = express();

var log4js = require('log4js');
log4js.configure({
    appenders: [
        {type: 'file', filename: 'logs/app.log', maxLogSize: 10485760, backups: 10, category: 'info'}
    ]
});
var logger = log4js.getLogger('info');

//var mongo = require('mongodb');
var db = require('monk')('localhost:27017/leetcode');

app.use(bodyParser.json({limit: '1mb'}));  //body-parser json format
// parse application/x-www-form-urlencoded
// app.use(bodyParser.urlencoded({ extended: false  }))
//app.use(bodyParser.urlencoded({            // this line must follow bodyParser.json
  //extended: true
//}));
// parse application/json
app.use(bodyParser.json());

app.get('/', func_root);
app.get('/leetcode-ext', func_leetcode);
app.get('/leetcode-ext/all_problems', get_all_problems);
app.get('/leetcode-ext/problem/:title', get_problem);
app.post('/leetcode-ext/problem', save_problem);

var server = app.listen(9199, "0.0.0.0", function() {
    var host = server.address().address;
    var port = server.address().port;
});

function func_root(req, res) {
    res.send("There is nothing here~");
}

function func_leetcode(req, res) {
    var data = fs.readFileSync("./leetcode.json", "utf-8");
    res.send(data);
    //res.jsonp(JSON.parse(data));
}

function get_all_problems(req, res) {
    var collection = db.get('problems');
    var data = {};
    collection.find({}, function(e, docs) {
        for (var i = 0; i < docs.length; ++i) {
            var p = docs[i].problem;
            var title = p.title;
            var companies = docs[i].companies;
            var tags = docs[i].tags;
            if (typeof(companies) == 'undefined' || !companies) companies = [];
            if (typeof(tags) == 'undefined' || !tags) tags = [];
{'fraction_non_alphanumeric': 0.1886842105263158, 'fraction_numerical': 0.016842105263157894, 'mean_word_length': 3.49290780141844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1721103', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1276, 'n_words': 275}