forked from Carl-Bohme/CS-290-Final-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
40 lines (30 loc) · 1 KB
/
server.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
var path = require('path');
var express = require('express');
var exphbs = require('express-handlebars');
var bodyParser = require('body-parser');
var recipeData = require('./recipeData');
var filterFoods = require('./views/partials/filterFoods');
var app = express();
var port = process.env.PORT || 3000;
app.engine('handlebars', exphbs({ defaultLayout: 'main' }));
app.set('view engine', 'handlebars');
app.use(bodyParser.json());
app.use(express.static('public'));
app.get('/', function (req, res, next) {
res.status(200).render('homePage');
});
app.get('/addRecipe', function (req, res, next) {
res.status(200).render('addRecipePage');
});
app.get('/results', function (req, res, next) {
res.status(200).render('searchResults', {
recipes: recipeData,
filter: filterFoods
});
});
app.get('*', function (req, res) {
res.status(404).render('404');
});
app.listen(port, function () {
console.log("== Server is listening on port", port);
});