-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
60 lines (53 loc) · 1.58 KB
/
app.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
57
58
59
60
var express = require("express");
var bodyParser = require("body-parser");
var request = require("request");
var Yelp = require('yelp');
var yelp = new Yelp({
consumer_key: process.env.CK,
consumer_secret: process.env.CS,
token: process.env.TKN,
token_secret: process.env.TKN_SCT
});
var port = process.env.PORT || 8080;
var app = express();
require('dotenv').config();
app.use(bodyParser.urlencoded({extended: true}));
app.use(express.static(__dirname + '/public'));
app.set("view engine", "ejs");
app.get("/", function(req, res){
res.render("home");
});
app.get("/pizza", function(req, res){
yelp.search({ term: "best slice of pizza", location: req.query.address, sort: 0 && 2,
limit: 3, radius_filter: 1000})
.then(function(data){
res.render("pizza", {data: data});
})
.catch(function (){
res.render("error");
console.log("errors");
})
});
app.get("/coffee", function(req, res){
yelp.search({ term: "best coffee", location: req.query.address, sort: 0 && 2,
limit: 3, radius_filter: 1000})
.then(function(data){
res.render("coffee", {data: data});
})
.catch(function (){
res.render("error");
})
});
app.get("/bagels", function(req, res){
yelp.search({ term: "best bagels", location: req.query.address, sort: 0 && 2,
limit: 3, radius_filter: 1000})
.then(function(data){
res.render("bagels", {data: data});
})
.catch(function (){
res.render("error");
});
});
app.listen(port, process.env.IP, function(){
console.log("PCB app has started!");
});