-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
78 lines (67 loc) · 2.23 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var express = require("express");
// create express app
var app = express();
app.set("view engine", "ejs");
app.set("views", __dirname + "/views");
app.use("/public", express.static("public"));
app.get("/", (req, res) => {
res.render("pages/landing");
});
app.get("/result", (req, res) => {
require('./bmiFunctions.js').bmiCalc(req.query.cm, req.query.kg, req.query.calculateWHR, req.query.gender, req.query.waist, req.query.hip,
function () {
res.redirect("/");
},
function (obj) {
res.render("pages/result", obj);
})
// var m = (parseInt(req.query.cm, 10) / 100);
// // console.log(req.query)
// var kg = req.query.kg;
// var calculateWHR = req.query.calculateWHR;
// if (m == 0 || isNaN(m)) {
// res.redirect("/");
// } else {
// var bmi = (kg / (m * m));
// var bmiGroup
// if (bmi < 18.5)
// bmiGroup = 'Underweight'
// else if (bmi < 25)
// bmiGroup = 'Healthy weight'
// else if (bmi < 30)
// bmiGroup = 'Overweight'
// else
// bmiGroup = 'Obese'
// // console.log(bmiGroup)
// var whr
// var whrClassification
// if (calculateWHR) {
// whr = req.query.waist / req.query.hip
// if (req.query.gender == "male") {
// if (whr < 0.9)
// whrClassification = 'normal weight'
// else if (whr < 1)
// whrClassification = 'over-weight'
// else
// whrClassification = 'obesity'
// }
// else {//female
// if (whr < 0.8)
// whrClassification = 'normal weight'
// else if (whr < 0.85)
// whrClassification = 'over-weight'
// else
// whrClassification = 'obesity'
// }
// }
// res.render("pages/result", {
// bmi: bmi,
// bmiGroup: bmiGroup,
// whr: whr,
// whrClassification: whrClassification
// });
// }
});
var port = 8080;
console.log("App is running on http://localhost:" + port)
app.listen(port);