<commit_before>'use strict';

var fs = require('fs');
var path = require('path');
var http = require('http');
var https = require('https');
var app = module.exports = require('./server/server');

if (require.main === module) {
    app.boot()
    .then(() => {
        let httpOnly = process.env.HTTP;
        if (typeof httpOnly === 'undefined') httpOnly = false;
        let server = null;
        if (httpOnly) {
            server = http.createServer(app);
        } else {
            let options = {
                key: fs.readFileSync(path.join('.', 'private', 'privatekey.pem')),
                cert: fs.readFileSync(path.join('.', 'private', 'certificate.pem'))
            };
            server = https.createServer(options, app);
        }
        server.listen(app.get('port'), () => {
            let baseUrl = `${httpOnly ? 'http' : 'https'}://${app.get('host')}:${app.get('port')}`;
            app.emit('started', baseUrl);
            if (app.get('env') === 'development') {
                console.log('Web server listening at: %s', baseUrl);
                if (app.get('loopback-component-explorer')) {
                    let explorerPath = app.get('loopback-component-explorer').mountPath;
                    console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
                }
            }
        });
    }, (err) => {
        console.error(`Error: ${err.message}`);
    });
}<commit_msg>add possibility to specify port for app<commit_after>'use strict';

var fs = require('fs');
var path = require('path');
var http = require('http');
var https = require('https');
var flags = require('node-flags');
var app = module.exports = require('./server/server');
var logger = require('./common/utils/logger');

if (require.main === module) {

    app.boot()
    .then(() => {
        let httpOnly = process.env.HTTP;
        let port =  flags.get('port') || app.get('port');

        if (typeof httpOnly === 'undefined') httpOnly = false;
        let server = null;
        if (httpOnly) {
            server = http.createServer(app);
        } else {
            let options = {
                key: fs.readFileSync(path.join('.', 'private', 'privatekey.pem')),
                cert: fs.readFileSync(path.join('.', 'private', 'certificate.pem'))
            };
            server = https.createServer(options, app);
        }
        server.listen(port, () => {
            let baseUrl = `${httpOnly ? 'http' : 'https'}://${app.get('host')}:${port}`;
            app.emit('started', baseUrl);
            if (app.get('env') === 'development') {
                console.log('Web server listening at: %s', baseUrl);
                if (app.get('loopback-component-explorer')) {
                    let explorerPath = app.get('loopback-component-explorer').mountPath;
                    console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
                }
            }
        });
    }, (err) => {
        if (NODE_ENV === 'development') {
            logger.error(`Error: ${err.stack}`);
        } else {
            logger.error(`Error: ${err.message}`);
        }
    });
}
{'fraction_non_alphanumeric': 0.18045352922389013, 'fraction_numerical': 0.0, 'mean_word_length': 2.0407766990291263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7668277', 'n_tokens_mistral': 916, 'n_tokens_neox': 896, 'n_words': 194}