<commit_before>var httpserver = require('http').createServer(httpGet)
, io = require('socket.io').listen(httpserver)
, fs = require('fs')
, st = require('./storage.js')
, sh = require('./lib/sha1_2.js').SHA1;

httpserver.listen(8081);
var storage = new st.Storage();
console.log("started");

function httpGet(req, res){
	console.log("httpGet - start - "+req.url);
	if(req.url==='/'){
		req.url = '/index.html';
	}
	fs.readFile(__dirname+req.url, function(err,data){
		if(err){
			res.writeHead(500);
			return res.end('Error loading ' + req.url);
		}
		if(req.url.indexOf('.js')>0){
			console.log("sending back js :"+req.url);
			res.writeHead(200, {
  				'Content-Length': data.length,
  				'Content-Type': 'application/x-javascript' });

		}
		else{
			res.writeHead(200);
		}
		res.end(data);
	});	
};

io.sockets.on('connection', function(socket){
	console.log("someone connected");
	socket.on('msg', function(data){
		console.log("got request"+data);
		var response = [];
		var commits = JSON.parse(data);
		for(var i in commits){
			if(commits[i].object===undefined){
				/*read request*/
				storage.get(commits[i].hash, function(result){
					if(result!=undefined){
						var resobj = {}; resobj.hash = commits[i].hash;resobj.object=result;
						response.push(resobj);
					}
				});
			}
			else{
				/*write operation*/
				console.log("calculated hash: "+sh(commits[i].object));
				console.log("received hash: "+commits[i].hash);
				storage.put(commits[i].hash,commits[i].object,function(){});
			}
		}
		socket.emit('msg', response);
	});
	socket.on('close',function(){
		console.log("connection closed");
	});
});<commit_msg>SHA1 calculation temporary removed from server side as the module cannot be properly loaded...<commit_after>var httpserver = require('http').createServer(httpGet)
, io = require('socket.io').listen(httpserver)
, fs = require('fs')
, st = require('./storage.js')
, sh = require('./lib/sha1_2.js');

httpserver.listen(8081);
var storage = new st.Storage();
console.log("started");

function httpGet(req, res){
	console.log("httpGet - start - "+req.url);
	if(req.url==='/'){
		req.url = '/index.html';
	}
	fs.readFile(__dirname+req.url, function(err,data){
		if(err){
			res.writeHead(500);
			return res.end('Error loading ' + req.url);
		}
		if(req.url.indexOf('.js')>0){
			console.log("sending back js :"+req.url);
			res.writeHead(200, {
  				'Content-Length': data.length,
  				'Content-Type': 'application/x-javascript' });

		}
		else{
			res.writeHead(200);
		}
		res.end(data);
	});	
};

io.sockets.on('connection', function(socket){
	console.log("someone connected");
	socket.on('msg', function(data){
		console.log("got request"+data);
		var response = [];
		var commits = JSON.parse(data);
		for(var i in commits){
			if(commits[i].object===undefined){
				/*read request*/
				storage.get(commits[i].hash, function(result){
					if(result!=undefined){
						var resobj = {}; resobj.hash = commits[i].hash;resobj.object=result;
						response.push(resobj);
					}
				});
			}
			else{
				/*write operation*/
				//console.log("calculated hash: "+SHA1(commits[i].object));
				console.log("received hash: "+commits[i].hash);
				storage.put(commits[i].hash,commits[i].object,function(){});					
			}
		}
		socket.emit('msg', response);
	});
	socket.on('close',function(){
		console.log("connection closed");
	});
});
{'fraction_non_alphanumeric': 0.20575155647791285, 'fraction_numerical': 0.010376519418914912, 'mean_word_length': 3.9690721649484537, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4361118', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1173, 'n_words': 194}