<commit_before>module.exports = ServerNode;

var util = require('util');
var EventEmitter = require('events').EventEmitter;
var nodemailer = require('nodemailer');

var http = require('http');
var fs = require('fs');
var path = require('path');

var ServerChannel = require('./ServerChannel');

function ServerNode (options, server, io) {

	this.options = options;
	
	this.options.mail = this.options.mail || false;
	this.options.dump = this.options.mail || true;
	this.port = options.port || '80'; // port of the express server and sio
	
	this.maxChannels = options.maxChannels;
	this.channels = [];
	
	this.listen(server, io);
}

ServerNode.prototype.createHTTPServer = function (options) {
	
	return http.createServer(function (request, response) {

	    // console.log('request starting...');
		
		var filePath = '.' + request.url;
		
		if (filePath === './' || filePath === './log') {
			filePath = './index.htm';
		}
		else if (filePath === './nodegame.js') {
			filePath = './nodegame/nodegame-all-latest.js';
		}
		
		
		var extname = path.extname(filePath);
		
		console.log(filePath);
		
		
		var contentType = 'text/html';
		switch (extname) {
			case '.js':
				contentType = 'text/javascript';
				break;
			case '.css':
				contentType = 'text/css';
				break;
		}
		
		path.exists(filePath, function(exists) {
		
			if (exists) {
				fs.readFile(filePath, function(error, content) {
					if (error) {
						response.writeHead(500);
						response.end();
					}
					else {
						response.writeHead(200, { 'Content-Type': contentType });
						response.end(content, 'utf-8');
					}
				});
			}
			else {
				console.log('Unexisting path requested.')<commit_msg>HTTP server should work on Windows as well now<commit_after>module.exports = ServerNode;

var util = require('util');
var EventEmitter = require('events').EventEmitter;
var nodemailer = require('nodemailer');

var http = require('http');
var fs = require('fs');
var path = require('path');

var ServerChannel = require('./ServerChannel');

function ServerNode (options, server, io) {

	this.options = options;
	
	this.options.mail = this.options.mail || false;
	this.options.dump = this.options.mail || true;
	this.port = options.port || '80'; // port of the express server and sio
	
	this.maxChannels = options.maxChannels;
	this.channels = [];
	
	this.listen(server, io);
}

ServerNode.prototype.createHTTPServer = function (options) {
	
	return http.createServer(function (request, response) {

	    // console.log('request starting...');
		
		var filePath = '.' + request.url;
		
		if (filePath === './' || filePath === './log') {
			filePath = './index.htm';
		}
		else if (filePath === './nodegame.js') {
			filePath = './nodegame/nodegame-all-latest.js';
		}
		
		// Added path.normalize here. TODO: Check if it works on windows.
		var extname = path.extname(path.normalize(filePath));
		
		console.log(filePath);
		
		
		var contentType = 'text/html';
		switch (extname) {
			case '.js':
				contentType = 'text/javascript';
				break;
			case '.css':
				contentType = 'text/css';
				break;
		}
		
		path.exists(filePath, function(exists) {
		
			if (exists) {
				fs.readFile(filePath, function(error, content) {
					if (error) {
						response.writeHead(500);
						response.end();
					}
					else {
						response.writeHead(200, { 'Content-Type': contentType });
						response.end(content, 'utf-8');
					}
				});
			}
			else {
				console.log('Unexisting path requested.')
{'fraction_non_alphanumeric': 0.16234140715109574, 'fraction_numerical': 0.005190311418685121, 'mean_word_length': 3.144563918757467, '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': '3814627', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1086, 'n_words': 247}