-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
58 lines (39 loc) · 1.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var express = require('express');
var request = require('request'); // "Request" library
var querystring = require('querystring');
var bodyParser = require('body-parser')
var app = express();
// parse application/json
app.use(bodyParser.json())
var router = express.Router();
// create application/json parser
var jsonParser = bodyParser.json()
// create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })
app.set('port', (process.env.PORT || 5000));
app.use(express.static(__dirname + '/public'));
GLOBAL.songs_array = new Array();
app.set('view engine', 'jade');
app.set('views', __dirname + '/views');
app.get('/', function(req, res) {
res.render('home', {title: 'home', songs_array: songs_array});
});
app.post('/', function(req, res) {
res.render('home', {title: 'home', songs_array: songs_array});
});
var generateRandomString = function(length) {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
};
/*** End of Spotify ***/
app.get('/about', function (req, res) {
// Render __dirname/views/download.jade
res.render('about', {title: 'about'});
});
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'));
});