What I am trying to do is when the user clicks the calculate button(not doing any calculations yet) it should redirect them to a new screen with with a response message which says "Thanks for posting that!". But instead of the message it would display my entire C:\ directory, I feel like it has something to do with the "/" as the route but in the tutorial that what they used.
here's my index.html
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>calculator</title>
</head>
<body>
<h1>Calculator</h1>
<form class="" action="/" method="post"> <!-- Send to home route-->
<input type="text" name="num1" placeholder="First Number">
<input type="text" name="num2" placeholder="Second Number">
<button type="submit" name="submit">Calculate</button>
</form>
</body>
</html>
Here's the server calculator.js
const express = require("express");
const app = express();
app.get("/", function(req,res){
res.sendFile(__dirname + "/index.html");
});
app.post("/", function(req,res){
res.send("Thanks for posting that!");
});
app.listen(3000,function(req,res){
console.log("server up");
});