<commit_before>#!/usr/bin/node

var fs = require('fs'),
	url = require('url'),
    connect = require('connect'),
    request = require('request'),
    
	oauthHtml = fs.readFileSync('resources/oauth.html', 'utf-8'),

    CLIENT_ID = process.env.GH_BASIC_CLIENT_ID,
    CLIENT_SECRET = process.env.GH_BASIC_SECRET_ID,
	oauthRequestUrl = 'https://github.com/login/oauth/authorize?client_id=' + CLIENT_ID,
	accessToken,

    oauthPitcher, oauthCatcher,
    travisHandler;

oauthHtml = oauthHtml.replace('{{client_id}}', CLIENT_ID);

oauthPitcher = function(req, res, next) {
    if (req.url != '/') {
        return next();
    }
    res.end(oauthHtml);
};

oauthCatcher = function(req, res, next) {
    // ignore all URLs that don't start /oauth_callback
    if (req.url.substr(0,15) != '/oauth_callback') {
        return next();
    }
    var sessionCode = url.parse(req.url, true).query.code;
	console.log('session code: ' + sessionCode);
    request.post(
        {
            url: 'https://github.com/login/oauth/access_token', 
			json: {
                client_id: CLIENT_ID,
                client_secret: CLIENT_SECRET,
                code: sessionCode
            }
        }, 
        function(err, oauthRes, body) {
            accessToken = body.access_token;
            console.log('access token: ' + accessToken);
            res.end();
        }
    );
};

travisHandler = function(req, res, next) {
    // ignore all URLs that don't start /travis
    if (req.url.substr(0,7) != '/travis') {
        return next();
    }
    console.log(req.body);
    res.end();
};

connect()
    .use(connect.logger('dev'))
    .use(connect.bodyParser())
    .use(oauthPitcher)
    .use(oauthCatcher)
    .use(travisHandler)
    .listen(3031);

<commit_msg>probably the same changes<commit_after>#!/usr/bin/node

var fs = require('fs'),
	url = require('url'),
    connect = require('connect'),
    request = require('request'),
    
	oauthHtml = fs.readFileSync('resources/oauth.html', 'utf-8'),

    CLIENT_ID = process.env.GH_BASIC_CLIENT_ID,
    CLIENT_SECRET = process.env.GH_BASIC_SECRET_ID,
	oauthRequestUrl = 'https://github.com/login/oauth/authorize?client_id=' + CLIENT_ID,
	accessToken,

    oauthPitcher, oauthCatcher,
    travisHandler;

oauthHtml = oauthHtml.replace('{{client_id}}', CLIENT_ID);

oauthPitcher = function(req, res) {
    res.end(oauthHtml);
};

oauthCatcher = function(req, res) {
    var sessionCode = url.parse(req.url, true).query.code;
	console.log('session code: ' + sessionCode);
    request.post(
        {
            url: 'https://github.com/login/oauth/access_token', 
			json: {
                client_id: CLIENT_ID,
                client_secret: CLIENT_SECRET,
                code: sessionCode
            }
        }, 
        function(err, oauthRes, body) {
            accessToken = body.access_token;
            console.log('access token: ' + accessToken);
            res.end();
        }
    );
};

travisHandler = function(req, res) {
    console.log(req.body);
    console.log('access token: ' + accessToken);
    res.end();
};

connect()
    .use(connect.logger('dev'))
    .use(connect.bodyParser())
    .use('/callback', oauthCatcher)
    .use('/travis', travisHandler)
    .use('/', oauthPitcher)
    .listen(3031);


{'fraction_non_alphanumeric': 0.15210751374465487, 'fraction_numerical': 0.004581551618814905, 'mean_word_length': 2.626799557032115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '429464', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1125, 'n_words': 184}