<commit_before>var express = require('express');
var router = express.Router();
var rest = require('restler')

/* GET home page. */
router.get('/', function(req, res) {
  res.render('index', { title: 'GIFScript' })
})

/* GET chat room */
router.get('/chat', function(req, res) {
  res.render('chat', { title: 'GIFScript' })
})

/* GET GIF form */
router.get('/gifs/new', function(req, res) {
  res.render('gif_form')
})

/* GET GIFs from Giphy search */
router.get('/gifs/search', function(req,res) {
  var queryString = req.query.giphysearch.split(" ").join("+")
  var giphySearchURL = 'http://api.giphy.com/v1/gifs/search?q=' + queryString + '&api_key=<KEY>'

  rest.get(giphySearchURL).on('complete', function(data) {
    var gifs = data.data
    var firstTenGIFs = []
    for (var i = 0; i <= gifs.length -1 && i <= 19; i++) {
      firstTenGIFs.push(gifs[i].images.downsized.url)
    }
    res.render('giphy_results', { urls: firstTenGIFs })
  })
})

module.exports = router;<commit_msg>adds minor refactoring of chat.js<commit_after>var express = require('express');
var router = express.Router();
var rest = require('restler')

/* GET home page. */
router.get('/', function(req, res) {
  res.render('index', { title: 'GIFScript' })
})

/* GET chat room */
router.get('/chat', function(req, res) {
  res.render('chat', { title: 'GIFScript' })
})

/* GET GIF form */
router.get('/gifs/new', function(req, res) {
  res.render('gif_form')
})

/* GET GIFs from Giphy search */
router.get('/gifs/search', function(req,res) {
  var queryString = req.query.giphysearch.split(" ").join("+")
  var giphySearchURL = 'http://api.giphy.com/v1/gifs/search?q=' + queryString + '&api_key=dc6zaTOxFJmzC'

  rest.get(giphySearchURL).on('complete', function(data) {
    var allGIFs = data.data
    var results = []
    for (var i = 0; i <= allGIFs.length -1 && i <= 19; i++) {
      results.push(allGIFs[i].images.downsized.url)
    }
    res.render('giphy_results', { urls: results })
  })
})

module.exports = router;
{'fraction_non_alphanumeric': 0.20169322709163345, 'fraction_numerical': 0.005478087649402391, 'mean_word_length': 3.8526570048309177, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 4, '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': '5346908', 'n_tokens_mistral': 759, 'n_tokens_neox': 749, 'n_words': 149}