<commit_before>var logger = require('./logger');

var ejs = require('ejs');

var fs = require("fs"),
	path = require("path");

var mimeTypes = {
  '.js' : 'text/javascript',
  '.html': 'text/html',
  '.css' : 'text/css',
  '.ejs': 'text/html',
};

var serverPath;

var staicFileHelper = function() {
  //logger.log("staicFilehelper constructed");
}

var json;
staicFileHelper.processFile = function (req,res,filePath) {
	//fs.exists(filePath, function (exists) { 
	    //if (exists) {
	      if(typeof res.requiredData==='undefined')
		{	
		      var headers = {'Content-type': mimeTypes[path.extname(filePath)]};
			logger.log('sfileheplerstattic--'+res.requiredData);
					
			if(typeof res.requiredData !=='undefined')
				{
					json = JSON.parse(res.requiredData);
				}
			ejs.renderFile(filePath,{json:json,filepath:serverPath,cache:true},
				function(err, result) {
					if (!err) {
						res.writeHead(200, headers);
						res.end(result);
					}
					// render or error
					else {
						res.writeHead(500);
						res.end('Internal Server Error... file path '
							+filePath+' server path '+serverPath);
						logger.log(err);
					}
			});
		      return;	
		}
	      else
		{
			logger.log('sfileheplerdynamic--'+res.requiredData);
			if(typeof res.requiredData !=='undefined')
				{
					json = JSON.parse(res.requiredData);
				}
		      var headers = {'Content-type': mimeTypes[path.extname(filePath)]};
			var json = JSON.parse(res.requiredData);
			ejs.renderFile(filePath,{json:json,filepath:serverPath,cache:true},
				function(err, result) {
					if (!err) {
						res.writeHead(200, headers);
						res.end(result);
					}
					// render or error
					else {
						logger.logInfo('Internal Server Error');
						logger.logWarn('Internal Server Error');
			
						res.writeHead(500);
						res.end('Internal Server Error... file path '+filePath+
							' server path '+serverPath + 'err '+err);
						logger.log(err);<commit_msg>solved the json variable related bug<commit_after>var logger = require('./logger');

var ejs = require('ejs');

var fs = require("fs"),
	path = require("path");

var mimeTypes = {
  '.js' : 'text/javascript',
  '.html': 'text/html',
  '.css' : 'text/css',
  '.ejs': 'text/html',
};

var serverPath;

var staicFileHelper = function() {
  //logger.log("staicFilehelper constructed");
}

var json = {};
staicFileHelper.processFile = function (req,res,filePath) {
	//fs.exists(filePath, function (exists) { 
	    //if (exists) {
	      if(typeof res.requiredData==='undefined')
		{	
		      var headers = {'Content-type': mimeTypes[path.extname(filePath)]};
			logger.log('sfileheplerstattic--'+res.requiredData);
			json = {};		
			if(typeof res.requiredData !=='undefined')
				{
					json = JSON.parse(res.requiredData);
				}
			ejs.renderFile(filePath,{json:json,filepath:serverPath,cache:true},
				function(err, result) {
					if (!err) {
						res.writeHead(200, headers);
						res.end(result);
					}
					// render or error
					else {
						res.writeHead(500);
						res.end('Probably the json variable property declaration are not right\n' 
							+'or other Server Error... file path '
							+filePath+' server path '+serverPath);
						logger.log(err);
					}
			});
		      return;	
		}
	      else
		{
			logger.log('sfileheplerdynamic--'+res.requiredData);
			json = {};
			if(typeof res.requiredData !=='undefined')
				{
					json = JSON.parse(res.requiredData);
				}
		      var headers = {'Content-type': mimeTypes[path.extname(filePath)]};
			var json = JSON.parse(res.requiredData);
			ejs.renderFile(filePath,{json:json,filepath:serverPath,cache:true},
				function(err, result) {
					if (!err) {
						res.writeHead(200, headers);
						res.end(result);
					}
					// render or error
					else {
						logger.logInfo('Internal Server Error');
						logger.logWarn('Internal Server Error');
			
						res.writeHead(500);
						res.end('Probably the json variable property declaration are not right\n' 
							+'or other Server Error... file path '
							+filePath+' server path '+serverPath);
						logger.log(err);
{'fraction_non_alphanumeric': 0.16198387490838015, 'fraction_numerical': 0.005863669679941363, 'mean_word_length': 2.940327237728585, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6309984', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1321, 'n_words': 262}