<commit_before>// REQUIRE DEPENDENCIES
var express = require('express')
var http = require('http')
var path = require('path')
var request = require('superagent')
var app = express()

// CONFIGURE SETTINGS
app.set('port', process.env.PORT || 3000)
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'jade')

// CONNECT TO DB

// DEFINE MIDDLEWARE

/*
 * Request Token from Artsy API
 */
var clientID = '00665d46bb4f56d42b98'
var clientSecret = '86d483720aa6dedc9c86d1129a995749'
var apiUrl = 'https://api.artsy.net/api/tokens/xapp_token'
var xappToken

request
  .post(apiUrl)
  .send({ client_id: clientID, client_secret: clientSecret })
  .end(function(err, res) {
    if (err) {
      return console.log('error')
    }
    xappToken = res.body.token;
    console.log(res.body)

    //getDegas();
  });

// DEFINE ROUTES
app.get('/', function(req, res) {
  res.render('index', {msg: 'Welcome to the Art(sy) History Flash Card Game!'})
})

app.get('/token', function(req, res) {
  res.render('degas', {msg: xappToken})
})

// START SERVER
//----------
http
  .createServer(app)
  .listen(
    app.get('port'),
    function() {
      console.log(
        'Express server listening on port ' +
        app.get('port')
      )
    }
  )
<commit_msg>Get and add Degas info to template page<commit_after>// REQUIRE DEPENDENCIES
var express = require('express')
var http = require('http')
var path = require('path')
var request = require('superagent')
var app = express()

// CONFIGURE SETTINGS
app.set('port', process.env.PORT || 3000)
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'jade')

// CONNECT TO DB

// DEFINE MIDDLEWARE

/*
 * Request Token from Artsy API
 */
var clientID = '00665d46bb4f56d42b98'
var clientSecret = '86d483720aa6dedc9c86d1129a995749'
var apiUrl = 'https://api.artsy.net/api/tokens/xapp_token'
var xappToken
var degas

request
  .post(apiUrl)
  .send({ client_id: clientID, client_secret: clientSecret })
  .end(function(err, res) {
    if (err) {
      return console.log('error')
    }
    xappToken = res.body.token;
    //console.log(res.body)

    getDegas();
  });

function getDegas() {
  request
    .get('https://api.artsy.net/api/artists/edgar-degas')
    .set('X-Xapp-Token', xappToken)
    .end(function(err, res) {
      if (err) {
        return console.log('error')
      }
      degas = '\n' + res.body.name + '\n' + 'Birthday: ' + res.body.birthday + '\n' + 'Hometown: ' + res.body.hometown + '\n' + 'Nationality: ' + res.body.nationality;
      //degasArtwork = res.body._links.artworks.href
      //getDegasArtwork()
      // this cb calls the function below to retrieve Degas info after auth token is generated
    })
}

// DEFINE ROUTES
app.get('/', function(req, res) {
  res.render('index', {msg: 'Welcome to the Art(sy) History Flash Card Game!'})
})

app.get('/token', function(req, res) {
  res.render('degas', {msg: degas})
})

// START SERVER
//-------------
http
  .createServer(app)
  .listen(
    app.get('port'),
    function() {
      console.log(
        'Express server listening on port ' +
        app.get('port')
      )
    }
  )

{'fraction_non_alphanumeric': 0.17091836734693877, 'fraction_numerical': 0.025510204081632654, 'mean_word_length': 3.138522427440633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, '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': '4051341', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1124, 'n_words': 255}