From 438b91c5ca809c624207532ad319ad85764ec6f6 Mon Sep 17 00:00:00 2001 From: Prateek Kumar Sahu <77916342+proPrateekSahu@users.noreply.github.com> Date: Sun, 30 Oct 2022 19:57:55 +0530 Subject: [PATCH] Website to calculate BMI of the person --- BMICalculator/bmicalculator.html | 17 +++++++++++++++++ BMICalculator/calculator.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 BMICalculator/bmicalculator.html create mode 100644 BMICalculator/calculator.js diff --git a/BMICalculator/bmicalculator.html b/BMICalculator/bmicalculator.html new file mode 100644 index 0000000..3ecb1ab --- /dev/null +++ b/BMICalculator/bmicalculator.html @@ -0,0 +1,17 @@ + + + + + + + BMI Calculator + + +

BMI Calculator

+
+ + + +
+ + diff --git a/BMICalculator/calculator.js b/BMICalculator/calculator.js new file mode 100644 index 0000000..6d1c85b --- /dev/null +++ b/BMICalculator/calculator.js @@ -0,0 +1,28 @@ +const bodyParser = require('body-parser'); +const express = require('express'); +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 a = Number(req.body.num1); + var b = Number(req.body.num2); + var result = a + b; + res.send('The addition of given two number is:' + result); +}); +app.get('/bmicalculator', function (req, res) { + res.sendFile(__dirname + '/bmicalculator.html'); +}); +app.post('/bmicalculator', function (req, res) { + var m = Number(req.body.ht); + var n = Number(req.body.wt); + var ans = n / (m * m); + res.send('The BMI for the given values is:' + ans); +}); +app.listen(3000, function () { + console.log('Server start on port 3000'); +});