-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (25 loc) · 736 Bytes
/
index.js
File metadata and controls
33 lines (25 loc) · 736 Bytes
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
var express = require('express');
var request = require('request');
var app = express();
var port = process.env.PORT || 3000;
if (!process.env.API) {
var env = require('./env.js');
}
app.use(express.static(__dirname));
app.get('/', function(req,res){
res.sendFile('index.html');
});
app.get('/concerts', function(req,res){
var key = process.env.API || env.apiKey;
var options = req.query;
var baseUrl = 'http://api.eventful.com/json/events/search?app_key=' + key;
var url = baseUrl;
Object.keys(options).forEach(function(key){
url += '&' + key + '=' + options[key];
});
//ajax request to eventful api
request(url, function(err, response, body) {
res.json(JSON.parse(body));
});
});
app.listen(port);