<commit_before>var connect = require("./lib/connect/lib/connect"),
    express = require("express"),
    http = require("http"),
    url = require("url");

var app = express.createServer();

app.configure(function(){
    app.use(app.router);
    app.use(connect.staticProvider({root: "..", exclude: /.*\/server\/.*/ig}));
});

app.get('/proxy', function(req, res){
    var hrefParam = req.param("href"),
        href = url.parse(hrefParam),
        options = {
            host: href.hostname,
            port: href.port || 80,
            path: (href.pathname || "") + (href.search || "")
        },
        len = 0;

    http.get(options, function(sourceRes) {
        sourceRes.on("data", function(chunk) {
            res.write(chunk);
            len += chunk.length;
        });
        sourceRes.on("end", function() {
            console.info("proxied url", hrefParam, "length", len, "status", sourceRes.statusCode);
            res.end();
        });

        res.writeHead(sourceRes.statusCode, sourceRes.headers);
    }).on("error", function(e) {
        console.info("error", e);
        res.send(502);
    });
});

app.listen(3000);<commit_msg>Allow config of the server port via env variable.<commit_after>var connect = require("./lib/connect/lib/connect"),
    express = require("express"),
    http = require("http"),
    url = require("url");

var app = express.createServer(),
    port = process.env.GRADIENT_SCANNER_PORT || 3000;

app.configure(function(){
    app.use(app.router);
    app.use(connect.staticProvider({root: "..", exclude: /.*\/server\/.*/ig}));
});

app.get('/proxy', function(req, res){
    var hrefParam = req.param("href"),
        href = url.parse(hrefParam),
        options = {
            host: href.hostname,
            port: href.port || 80,
            path: (href.pathname || "") + (href.search || "")
        },
        len = 0;

    http.get(options, function(sourceRes) {
        sourceRes.on("data", function(chunk) {
            res.write(chunk);
            len += chunk.length;
        });
        sourceRes.on("end", function() {
            console.info("proxied url", hrefParam, "length", len, "status", sourceRes.statusCode);
            res.end();
        });

        res.writeHead(sourceRes.statusCode, sourceRes.headers);
    }).on("error", function(e) {
        console.info("error", e);
        res.send(502);
    });
});

console.log("Starting gradient scanner server on port", port);
app.listen(port);
{'fraction_non_alphanumeric': 0.1855002025111381, 'fraction_numerical': 0.008100445524503848, 'mean_word_length': 2.425797503467406, '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': '1147422', 'n_tokens_mistral': 761, 'n_tokens_neox': 738, 'n_words': 139}