<commit_before>'use strict';

var gulp = require('gulp');
var node_static = require('node-static');
var chalk = require('chalk');
var moment = require('moment');
var fs = require('fs');

gulp.task('serve', function() {

    var server = new node_static.Server('./site/');

    require('http').createServer(function(request, response) {
        request.addListener('end', function() {
            server.serve(request, response, function(err, result) {

                var color;
                var status;
                var end = true;

                if (err) {

                    if (err.status === 404 && fs.existsSync(
                        './site/404.html')) {

                        end = false;

                        server.serveFile('404.html', 404, {},
                            request, response);

                    } else {
                        response.writeHead(err.status, err.headers);
                    }

                    color = err.status < 500 ? chalk.yellow :
                        chalk.red;
                    status = err.status;
                } else {

                    color = chalk.green;
                    status = response.statusCode;
                }

                console.log('[' + chalk.gray(moment().format(
                        'HH:mm:ss')) + '] [' + color(status) +
                    '] ' + color(request.url));<commit_msg>Have different colors for different statuses<commit_after>'use strict';

var gulp = require('gulp');
var node_static = require('node-static');
var chalk = require('chalk');
var moment = require('moment');
var fs = require('fs');

gulp.task('serve', function () {

    var server = new node_static.Server('./site/');

    require('http').createServer(function (request, response) {
        request.addListener('end', function () {
            server.serve(request, response, function (err, result) {

                var color;
                var status;
                var end = true;

                if (err) {

                    if (err.status === 404 && fs.existsSync(
                        './site/404.html')) {

                        end = false;

                        server.serveFile('404.html', 404, {},
                            request, response);

                    } else {
                        response.writeHead(err.status, err.headers);
                    }

                    status = err.status;

                } else {
                    status = response.statusCode;
                }

                switch (true) {
                case status >= 500:
                    color = chalk.red;
                    break;
                case status >= 400:
                    color = chalk.yellow;
                    break;
                case status >= 300:
                    color = chalk.cyan;
                    break;
                case status >= 200:
                    color = chalk.green;
                    break;
                case status >= 100:
                    color = chalk.magenta;
                    break;
                }

                console.log('[' + chalk.gray(moment().format(
                        'HH:mm:ss')) + '] [' + color(status) +
                    '] ' + color(request.url));
{'fraction_non_alphanumeric': 0.12263575350823673, 'fraction_numerical': 0.012812690665039659, 'mean_word_length': 1.1292207792207791, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '4960708', 'n_tokens_mistral': 877, 'n_tokens_neox': 747, 'n_words': 173}