<commit_before>var express = require('express');
var fs = require('fs');
var path = require('path');
var router = express.Router();


//保存base64图片POST方法
router.all('/uploadBase64Data', function (req, res, next) {
    var imgData = req.body.imgData || '';
    var kind = req.body.kind;
    //过滤data:URL
    var base64Data = imgData.replace(/^data:image\/\w+;base64,/, "");
    var dataBuffer = new Buffer(base64Data, 'base64');

    var uuid = new Date().getTime();
    var filename = "canvs-" + uuid + '.jpeg';
    fs.writeFile( '/upload/photo/' + filename, dataBuffer, function (err) {
        if (err) {
            res.send({
                status: '0',
                url: '',
                content: "error"
            });
        } else {
            var url ='http://10.16.48.40/nodejs/photo/' + filename;
            console.log(url);
            res.send({
                status: '200',
                url: url,
                content: "success"
            });
        }
    });
});
/* GET home page. */
router.get('/', function (req, res, next) {
    res.render('index', {title: 'nodejs min Server'});
});

module.exports = router;
<commit_msg>change upload dir<commit_after>var express = require('express');
var fs = require('fs');
var path = require('path');
var router = express.Router();
var ROOT_PATH = path.normalize(path.join(__dirname, '../'));

//保存base64图片POST方法
router.all('/uploadBase64Data', function (req, res, next) {
    var imgData = req.body.imgData || '';
    var kind = req.body.kind;
    //过滤data:URL
    var base64Data = imgData.replace(/^data:image\/\w+;base64,/, "");
    var dataBuffer = new Buffer(base64Data, 'base64');

    var uuid = new Date().getTime();
    var filename = "canvs-" + uuid + '.jpeg';
    fs.writeFile( ROOT_PATH+'/public/photo/' + filename, dataBuffer, function (err) {
        if (err) {
            res.send({
                status: '0',
                url: '',
                content: "error"
            });
        } else {
            var url ='http://10.16.48.40/nodejs/photo/' + filename;
            console.log(url);
            res.send({
                status: '200',
                url: url,
                content: "success"
            });
        }
    });
});
/* GET home page. */
router.get('/', function (req, res, next) {
    res.render('index', {title: 'nodejs min Server'});
});

module.exports = router;

{'fraction_non_alphanumeric': 0.17723102585487907, 'fraction_numerical': 0.020016680567139282, 'mean_word_length': 1.9912718204488777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6837956', 'n_tokens_mistral': 781, 'n_tokens_neox': 747, 'n_words': 173}