<commit_before>module.exports = function(app) {
  var mongoose = require('mongoose'); // require mongoose (for mongodb integration
  var fs = require('fs'); // necessary to read from files
  var db = require('./app_api/models/db'); // handles database connection open/close
  
  var routesApi = require('./app_api/routes/index');
  app.use('/api', routesApi); // provide routes in API route index

  fs.readFile('.dbconfig', 'utf8', function(err,data){
     if (err) {
          console.log(err);
     } else {
          var dbAccess = JSON.parse(data); // if read successful, parse JSON into object
          db(dbAccess.url, dbAccess.user, dbAccess.password); // connect to database
     }
  });
  

  app.get('/api/hello', function(request, response) { // provide RESTful GET API at /hello
      response.send('Hello, World!'); // respond with string
  });

  app.listen(process.env.PORT, process.env.IP); // begin app listening on Cloud9 port/IP

  console.log('API running!');
}<commit_msg>Modify app to expect IP/Port from .config, or use Cloud9 Port/IP if none found.<commit_after>module.exports = function(app) {
  var mongoose = require('mongoose'); // require mongoose (for mongodb integration
  var fs = require('fs'); // necessary to read from files
  var db = require('./app_api/models/db'); // handles database connection open/close
  
  var routesApi = require('./app_api/routes/index');
  app.use('/api', routesApi); // provide routes in API route index

  fs.readFile('.config', 'utf8', function(err,data){
    if (err) {
      console.log(err);
    } else {
        var config = JSON.parse(data); // if read successful, parse JSON into object
        db(config.url, config.user, config.password); // connect to database
          
        app.get('/api/hello', function(request, response) { // provide RESTful GET API at /hello
            response.send('Hello, World!'); // respond with string
        });
        
        app.listen(config.port || process.env.PORT, config.ip || process.env.IP); // try to open port/ip and try to use Cloud9 Port/IP if none specified
        
        console.log('API running!');
    }
  });
}
{'fraction_non_alphanumeric': 0.14445479962721341, 'fraction_numerical': 0.002329916123019571, 'mean_word_length': 2.903636363636364, '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': '2022765', 'n_tokens_mistral': 619, 'n_tokens_neox': 616, 'n_words': 188}