<commit_before>var express = require('express');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
var global_base_url = "https://web.spaggiari.eu/home/app/default/";
var base_url = "https://web.spaggiari.eu/cvv/app/default/";


app.get('/', function (req, res) {
	res.send("<h1>It Works!</h1>")
});


app.get('/:custcode/:usercode/:password', function (req, res) {
	var url = global_base_url + "login.php?custcode="+ req.params.custcode +"&login="+ req.params.usercode +"&password="+ req.params.password + "&mode=custcode";
	var jar = request.jar();
	request({url: url, jar: jar}, function(error, response, body) {
		  $ = cheerio.load(body);
		  if ($('.name').length) {
		  	res.send('{"status":"OK", "sessionId":"' + jar.getCookies(url)[0].value + '"}');
		  } else {
		  	res.send('{"status":"error"}');
		  }
	});
});


/* TODO: esempio accesso semplice */
app.get('/edoardo', function(req, res) {

	var url = global_base_url + "login.php?custcode=PSIT0008&login=G799661H&password=<PASSWORD>&mode=custcode";
	var jar = request.jar();<commit_msg>Aggiunta /profile<commit_after>var express = require('express');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
var global_base_url = "https://web.spaggiari.eu/home/app/default/";
var base_url = "https://web.spaggiari.eu/cvv/app/default/";


/**
 * Funzioni 
 */
app.get('/:sessionId/profile', function (req, res) {
	var profile = new Object();
	var check = true;
	var url = null;
	
	// # nome alunno e nome scuola
	url = global_base_url + "menu_webinfoschool_genitori.php";
	request({url: url, /*jar: jar*/ headers: {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0',
	            'Set-Cookie': "PHPSESSID=" + req.params.sessionId,
	            'Cookie': "PHPSESSID=" + req.params.sessionId}
	}, function(error, response, body) {
		$ = cheerio.load(body);
		if ($('.name').length) {
			// profile['status'] = "OK";
			profile['name'] = $('.name').text();
			profile['school'] = $('.scuola').text();
			// res.send(JSON.stringify(result));
		} else {
			check = false;
			// res.send('{"status":"error"}');
		}
	});
	
	// # nome classe
	url = base_url + "regclasse.php";
	request({url: url, /*jar: jar*/ headers: {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0',
	            'Set-Cookie': "PHPSESSID=" + req.params.sessionId,
	            'Cookie': "PHPSESSID=" + req.params.sessionId}
	}, function(error, response, body) {
		$ = cheerio.load(body);
		
		if ($('.page_title_variable').length) {
			profile['class'] = $('.page_title_variable').eq(0).text();
		} else check = false;	
		
	});
	
	// # Check finale e spedizione 
	if(!check) {
		res.send('{"status":"error"}');
	} else {
		res.send(JSON.stringify(profile));
	}
	
});


app.get('/', function (req, res) {
	res.send("<h1>It Works!</h1>")
});


app.get('/:custcode/:usercode/:password', function (req, res) {
	var url = global_base_url + "login.php?custcode="+ req.params.custcode +"&login="+ req.params.usercode +"&password="+ req.params.password + "&mode=custcode";
	var jar = request.jar();
	request({url: url, jar: jar}, function(error, response, body) {
		  $ = cheerio.load(body);
		  if ($('.name').length) {
		  	res.send('{"status":"OK", "sessionId":"' + jar.getCookies(url)[0].value + '"}');
		  } else {
		  	res.send('{"status":"error"}');
		  }
	});
});


/* TODO: esempio accesso semplice */
app.get('/edoardo', function(req, res) {

	var url = global_base_url + "login.php?custcode=PSIT0008&login=G799661H&password=<PASSWORD>&mode=custcode";
	var jar = request.jar();
{'fraction_non_alphanumeric': 0.2200983069361005, 'fraction_numerical': 0.019388312397596943, 'mean_word_length': 4.066390041493776, 'pattern_counts': {'":': 8, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '7072633', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1355, 'n_words': 244}