-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
57 lines (46 loc) · 1.28 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var path = require('path');
var express = require('express');
var exphbs = require('express-handlebars');
var exerciseData = require('./exerciseData.json');
var fs = require('fs')
var app = express();
var port = process.env.PORT || 3000;
app.engine('handlebars', exphbs.engine({
defaultLayout: "main"
}))
app.set('view engine', 'handlebars')
app.use(express.static('public'));
app.get('/', function(req, res,){
res.status(200).render('./partials/home');
});
app.get('/aboutUs', function(req, res){
res.status(200).render('./partials/aboutUs');
});
app.get('/LinkedIn', function(req, res){
res.status(200).render('./partials/LinkedIn');
});
app.get('/diet', function(req, res)
{
res.status(200).render('./partials/dietPage');
});
app.get('/exercise/:n', function (req, res, next) {
var n = req.params.n.toLowerCase();
if(exerciseData[n]){
res.status(200).render('./partials/exercisePage', {
exerciseData: [exerciseData[n]]
});
} else {
next();
}
});
app.get('/exercise', function(req, res){
res.status(200).render('./partials/exercisePage', {
exerciseData: exerciseData
});
});
app.get("*", function (req, res) {
res.status(404).render('./partials/404')
});
app.listen(port, function () {
console.log("== Server is listening on port", port);
});