This is a simple bmi calculator and a normal calculator that can add numbers. The html form loads correct to the browser but then once I submit the form, I get a 500 error code on /bmicalculator route alone.
The normal calculator route is working fine ("/").

Error code :

> 
> RangeError [ERR\_HTTP\_INVALID\_STATUS\_CODE]: Invalid status code:
> 0.0027180899908172637
> at ServerResponse.writeHead (\_http\_server.js:255:11)
> at ServerResponse.\_implicitHeader (*http\_server.js:246:8)
> at write* (\_http\_outgoing.js:685:9)
> at ServerResponse.end (\_http\_outgoing.js:799:5)
> at ServerResponse.send (G:\WebDevelopmentFolder\Calculator\node\_modules\express\lib\response.js:221:10)
> at G:\WebDevelopmentFolder\Calculator\calculator.js:36:7
> at Layer.handle [as handle\_request] (G:\WebDevelopmentFolder\Calculator\node\_modules\express\lib\router\layer.js:95:5)
> at next (G:\WebDevelopmentFolder\Calculator\node\_modules\express\lib\router\route.js:137:13)
> at Route.dispatch (G:\WebDevelopmentFolder\Calculator\node\_modules\express\lib\router\route.js:112:3)
> at Layer.handle [as handle\_request] (G:\WebDevelopmentFolder\Calculator\node\_modules\express\lib\router\layer.js:95:5)
> 
> 
> 

**bmicalculator.html:**

```
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>BMI Calculator</title>
  </head>
  <body>
    <h1>BMI Calculator</h1>
    <form action="/bmicalculator" method="post">
      <input type="text" name="weight" placeholder="weight">
      <input type="text" name="height" placeholder="height">
      <button type="submit">Calculate BMI</button>
    </form>
  </body>
</html>

```

**calculator.js:**

```
//jshint esversion:6

const express = require('express');
const bodyParser = require('body-parser');

const app = express();
app.use(bodyParser.urlencoded({extended: true}));

//sending response
app.get("/",function(req, res){
  res.sendFile(__dirname + "/index.html");
});

//post
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 is: "+result);
});

//get
app.get("/bmicalculator",function(req, res){
  res.sendFile(__dirname + "/bmicalculator.html");
});

//post
app.post("/bmicalculator",function(req, res){

  var weight = parseFloat(req.body.weight);
  var height = parseFloat(req.body.height);
  var bmi = weight/(height * height);

  res.send("Your BMI is: ", bmi);
});

//listen to port 3000
app.listen(3000, function(){
  console.log("Server listening on port 3000");
});

```