<commit_before>// B A S I C 	C O N F I G
var http_port = 80;
var https_port = 443;
var ssl_path= 'crt/ssl.key';


//R E Q U I R E S 
var express = require('express')
var app = express();
var http = require('http'); 
var https = require('https');
var cons = require('consolidate')
var childProcess = require('child_process');
var path =require("path");
var phantomjs = require('phantomjs/lib/phantomjs');
var binPath = phantomjs.path
var fs = require("fs");
var ssl_path= 'crt/ssl.key';
var bodyParser = require('body-parser');
var session = require('express-session');

app.set('views', __dirname + '/views');
app.engine('html', cons.handlebars);
app.set('view engine', 'html');



app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(session({ resave: true,
	      saveUninitialized: true,
	      secret: 'uwotm8' }));

app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'src')));
app.use('/test', express.static(__dirname + '/test'));
app.use('/screenshots', express.static(__dirname + '/screenshots'));
app.use('/Auditor',express.static(path.join(__dirname, 'src/HTML_CodeSniffer/Auditor')));    
app.use('/Images',express.static(path.join(__dirname, 'src/HTML_CodeSniffer/Auditor/Images')));


if (fs.existsSync(ssl_path)) {
		var hskey = fs.readFileSync(ssl_path);
		var hscert = fs.readFileSync('cert/abc.cer') ; 	//Replace here with your certificate file
		var options = {
		    key: hskey,
		    cert: hscert
		};
		var httpsServer = https.createServer(options, app);
		httpsServer.listen(https_port);
		console.log('Express started on port ' + https_port);	

} else {
		var server = http.createServer(app);
		app.listen(http_port);				// Start with Sudo for starting in default port		
		console.log('Express started on port ' + http_port);
}

	app.get('/', function(req, res) {
		res.render('index.html',{data:''});
	});

	app.get('/help', function(req, res) {
		res.render('help.html');
	});

	app.get('/getURL', function(req, res) {
		res.render('index.html',{data:''});
	});

	app.post('/sniffURL', function(req, res) {
 		var childArgs
 		, userName = ''
 		, d = new Date()
        , customDateString = d.getHours() +'_'  + d.getMinutes() + '_' + d.getSeconds() +'_'+ d.getMonth() + '_' + d.getDate() + '_' + d.getFullYear()
        , dirName = "screenshots/" + customDateString
        , scrshot = req.body.scrshot
        , msgErr = req.body.msgErr
        , msgWarn = req.body.msgWarn
        , msgNotice = req.body.msgNotice
    	, eLevel=[]

    	if(typeof msgErr !== 'undefined' && msgErr=='true') eLevel.push(1);
    	if(typeof msgWarn !== 'undefined' && msgWarn=='true') eLevel.push(2);
    	if(typeof msgNotice !== 'undefined' && msgNotice=='true') eLevel.push(3);

    	//Default to Error
		if(typeof msgErr === 'undefined' &&  typeof msgWarn === 'undefined' && typeof msgNotice === 'undefined') eLevel.push(1);

		fs.mkdirSync(dirName);		//Create SCREEN SHOT DIRECTORY

		// console.log(req.body);

		if (typeof req.session.userName !== 'undefined') {
			userName = req.session.userName;
			console.log('Testing logged in session: -> ', userName)
		}
		childArgs = ['--config=config/config.json', path.join(__dirname, 'src/PAET.js')
						, req.body.textURL
						, 'WCAG2AA'
						, userName
						, dirName
						, scrshot
						, eLevel
					];
		childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
			res.json({ userName: userName, data: stdout });
			console.log(stdout);
		});
	});

	app.post('/sniffHTML', function(req, res) {
 		var childArgs
 		, userName = ''
 		, d = new Date()
		, tempFilename = 'tmp/'+ new Date().getTime() + '.html'

			// console.log('source HTML --> ', req.body.source);

			var source = '<!DOCTYPE html><html lang="en"><meta charset="utf-8"><head><title>Home - PayPal Accessibility Tool</title></head><body>'
						+ 	req.body.source
						+ '</body></html>';

			fs.writeFile(tempFilename, source , function (err,data) {
			  if (err) {
			    return console.log(err);
			  }

			var childArgs = ['--config=config/config.json', path.join(__dirname, 'src/HTMLCS_Run.js'), tempFilename, 'WCAG2AA', 'P1,P2,P3,P4']
			 	childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
				res.json(stdout);
				console.log(stdout);
			});

		});
	});

	app.post('/login', function(req, res) {
		var userName= req.body.userName,
			password =<PASSWORD>,
			stageName = req.body.stageName,
			server = req.body.server

			console.log(userName, password, stageName, server);
			req.session.userName = userName;

		var childArgs1 = ['--config=config/config.json', path.join(__dirname, 'src/login.js'), userName, password, stageName, server]
			childProcess.execFile(binPath, childArgs1, function(err, stdout, stderr) {
			res.json({ userName: userName, data: stdout });
			console.log(stdout);		 
		});
	});

	app.get('/logout', function(req, res) {
		if (typeof req.session.userName !== 'undefined'){
				var fs = require('fs');
				fs.unlink(req.session.userName+'.txt', function (err) {
					if (err) throw err;
					console.log('successfully deleted cookies');
				});
				delete req.session.userName;
			}
			res.redirect('/');	
	});

<commit_msg>Add config for SSL cert file<commit_after>// B A S I C 	C O N F I G
var http_port = 80;		// Start with Sudo for starting in  port 80 or 443
var https_port = 443;
var ssl_path= 'crt/ssl.key';
var cert_file = 'cert/abc.cer';


//R E Q U I R E S 
var express = require('express')
var app = express();
var http = require('http'); 
var https = require('https');
var cons = require('consolidate')
var childProcess = require('child_process');
var path =require("path");
var phantomjs = require('phantomjs/lib/phantomjs');
var binPath = phantomjs.path
var fs = require("fs");
var bodyParser = require('body-parser');
var session = require('express-session');


app.set('views', __dirname + '/views');
app.engine('html', cons.handlebars);
app.set('view engine', 'html');


app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
	extended: true
}));
app.use(session({ resave: true,
	      saveUninitialized: true,
	      secret: 'uwotm8' }));

app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'src')));
app.use('/test', express.static(__dirname + '/test'));
app.use('/screenshots', express.static(__dirname + '/screenshots'));
app.use('/Auditor',express.static(path.join(__dirname, 'src/HTML_CodeSniffer/Auditor')));    
app.use('/Images',express.static(path.join(__dirname, 'src/HTML_CodeSniffer/Auditor/Images')));


if (fs.existsSync(ssl_path)) {
		var hskey = fs.readFileSync(ssl_path);
		var hscert = fs.readFileSync(cert_file) ; 	
		var options = {
		    key: hskey,
		    cert: hscert
		};
		var httpsServer = https.createServer(options, app);
		httpsServer.listen(https_port);
		console.log('Express started on port ' + https_port);	

} else {
		var server = http.createServer(app);
		app.listen(http_port);					
		console.log('Express started on port ' + http_port);
}

	app.get('/', function(req, res) {
		res.render('index.html',{data:''});
	});

	app.get('/help', function(req, res) {
		res.render('help.html');
	});

	app.get('/getURL', function(req, res) {
		res.render('index.html',{data:''});
	});

	app.post('/sniffURL', function(req, res) {
 		var childArgs
 		, userName = ''
 		, d = new Date()
        , customDateString = d.getHours() +'_'  + d.getMinutes() + '_' + d.getSeconds() +'_'+ d.getMonth() + '_' + d.getDate() + '_' + d.getFullYear()
        , dirName = "screenshots/" + customDateString
        , scrshot = req.body.scrshot
        , msgErr = req.body.msgErr
        , msgWarn = req.body.msgWarn
        , msgNotice = req.body.msgNotice
    	, eLevel=[]

    	if(typeof msgErr !== 'undefined' && msgErr=='true') eLevel.push(1);
    	if(typeof msgWarn !== 'undefined' && msgWarn=='true') eLevel.push(2);
    	if(typeof msgNotice !== 'undefined' && msgNotice=='true') eLevel.push(3);

    	//Default to Error
		if(typeof msgErr === 'undefined' &&  typeof msgWarn === 'undefined' && typeof msgNotice === 'undefined') eLevel.push(1);

		fs.mkdirSync(dirName);		//Create SCREEN SHOT DIRECTORY

		// console.log(req.body);

		if (typeof req.session.userName !== 'undefined') {
			userName = req.session.userName;
			console.log('Testing logged in session: -> ', userName)
		}
		childArgs = ['--config=config/config.json', path.join(__dirname, 'src/PAET.js')
						, req.body.textURL
						, 'WCAG2AA'
						, userName
						, dirName
						, scrshot
						, eLevel
					];
		childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
			res.json({ userName: userName, data: stdout });
			console.log(stdout);
		});
	});

	app.post('/sniffHTML', function(req, res) {
 		var childArgs
 		, userName = ''
 		, d = new Date()
		, tempFilename = 'tmp/'+ new Date().getTime() + '.html'

			// console.log('source HTML --> ', req.body.source);

			var source = '<!DOCTYPE html><html lang="en"><meta charset="utf-8"><head><title>Home - PayPal Accessibility Tool</title></head><body>'
						+ 	req.body.source
						+ '</body></html>';

			fs.writeFile(tempFilename, source , function (err,data) {
			  if (err) {
			    return console.log(err);
			  }

			var childArgs = ['--config=config/config.json', path.join(__dirname, 'src/HTMLCS_Run.js'), tempFilename, 'WCAG2AA', 'P1,P2,P3,P4']
			 	childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
				res.json(stdout);
				console.log(stdout);
			});

		});
	});

	app.post('/login', function(req, res) {
		var userName= req.body.userName,
			password =<PASSWORD>,
			stageName = req.body.stageName,
			server = req.body.server

			console.log(userName, password, stageName, server);
			req.session.userName = userName;

		var childArgs1 = ['--config=config/config.json', path.join(__dirname, 'src/login.js'), userName, password, stageName, server]
			childProcess.execFile(binPath, childArgs1, function(err, stdout, stderr) {
			res.json({ userName: userName, data: stdout });
			console.log(stdout);		 
		});
	});

	app.get('/logout', function(req, res) {
		if (typeof req.session.userName !== 'undefined'){
				var fs = require('fs');
				fs.unlink(req.session.userName+'.txt', function (err) {
					if (err) throw err;
					console.log('successfully deleted cookies');
				});
				delete req.session.userName;
			}
			res.redirect('/');	
	});


{'fraction_non_alphanumeric': 0.1825160733135016, 'fraction_numerical': 0.0041262834660781116, 'mean_word_length': 3.7051918735891647, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, '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': '3530239', 'n_tokens_mistral': 3983, 'n_tokens_neox': 3553, 'n_words': 735}