-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalculator.js
45 lines (25 loc) · 833 Bytes
/
calculator.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
const express =require("express");
const bodyparser=require("body-parser");
const app=express();
app.use(bodyparser.urlencoded({extended:true}));
app.get("/",function(req,res){
res.sendFile(__dirname+ "/index.html");
});
app.post("/",function(req,res){
var num1=Number(req.body.num1);
var num2=Number(req.body.num2);
var result=num1+num2;
res.send("The result of calculation is "+result);
});
app.get("/bmicalculator",function(req,res){
res.sendFile(__dirname+"/bmicalculator.html");
});
app.post("/bmicalculator",function(req,res){
var weight = console.log(parseFloat(req.body.weight));
var height=parseFloat(req.body.height);
var bmi=weight/(height*height);
res.send("the bmi calculate the result::"+bmi);
});
app.listen(3000,function(){
console.log("port is start::");
});