<commit_before>//get libraries required
var express = require('express');
var app = express();
var req = require('request');
var spotifyToken;//store the token once authenticated
app.use('static', express.static(__dirname));//set the base directory to find resources
/*
* Function that gets initialized when navigating to base url, sends back index.html
* and gets authentication token from spotify
*/
app.get('/', function (request, response) {
  getToken();
  response.sendFile(__dirname + '/index.html');
});
/*
* Start up node and listen on a specified port
*/
listener = app.listen(process.env.PORT, function () {
  console.log('Your app is listening on port ' + listener.address().port);
});
/*
* Function to get client credentials token from spotify
*/
function getToken() {
  /*
  * Authentication options used by spotify api for client credentials work flow
  */
  var authOptions = {
    url: 'https://accounts.spotify.com/api/token',
    headers: {
      'Authorization': 'Basic ' + (new Buffer(process.env.client_id + ':' + process.env.client_secret).toString('base64'))
    },
    form: {
      grant_type: 'client_credentials'
    },
    json: true
  };
  //post to spotify requesting token
  req.post(authOptions, function(error, response, body) {
  if (!error && response.statusCode === 200) {//if status 200
    spotifyToken = body.access_token;
  }
  });
}<commit_msg>Added getcategories and getplaylist functions to server.js.<commit_after>//get libraries required
var express = require('express');
var app = express();
var req = require('request');
var spotifyToken, categories, playList;
app.use('static', express.static(__dirname));//set the base directory to find resources
/*
* Function that gets initialized when navigating to base url, sends back index.html
* and gets authentication token from spotify
*/
app.get('/', function (request, response) {
  getToken();
  response.sendFile(__dirname + '/index.html');
});
/*
* Start up node and listen on a specified port
*/
listener = app.listen(process.env.PORT, function () {
  console.log('Your app is listening on port ' + listener.address().port);
});
/*
* Function to get client credentials token from spotify
*/
function getToken() {
  /*
  * Authentication options used by spotify api for client credentials work flow
  */
  var authOptions = {
    url: 'https://accounts.spotify.com/api/token',
    headers: {
      'Authorization': 'Basic ' + (new Buffer(process.env.client_id + ':' + process.env.client_secret).toString('base64'))
    },
    form: {
      grant_type: 'client_credentials'
    },
    json: true
  };
  //post to spotify requesting token
  req.post(authOptions, function(error, response, body) {
  if (!error && response.statusCode === 200) {//if status 200
    //spotifyToken = body.access_token;//store token
    //getCategories(spotifyToken, 'pop');
    //getPlayList(spotifyToken, 'spotify', '5FJXhjdILmRA2z5bvz4nzf');
  }
  });
}
function getCategories(spotifyToken, category) {
  var searchInfo = {
    url: 'https://api.spotify.com/v1/browse/categories/' + category + '/playlists',
    headers: {
      'Authorization': 'Bearer ' + spotifyToken
    }
  };
  req.get(searchInfo, function(error, response, body) {
    if (!error && response.statusCode === 200) {//if status 200
      categories = body;
      console.log(categories);
    }
  });
}
function getPlayList(spotifyToken, user, playListId) {
  var searchInfo = {
    url: 'https://api.spotify.com/v1/users/' + user + '/playlists/' + playListId,
    headers: {
      'Authorization': 'Bearer ' + spotifyToken
    }
  };
  req.get(searchInfo, function(error, response, body) {
    if (!error && response.statusCode === 200) {//if status 200
       playList = body;
       console.log(playList);
    }
  });
}
{'fraction_non_alphanumeric': 0.14353940037145133, 'fraction_numerical': 0.009020960466967366, 'mean_word_length': 3.7125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '439075', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1116, 'n_words': 314}