As a newcomer to the world of node.js, I find myself a bit lost when it comes to adding text colors, backgrounds, alignments, etc., to my node.js document. Can someone please provide me with a solution that will allow me to display the result sum = 12 in red?
Below is the code snippet I have provided. Any suggestions on how to achieve what I am looking for would be greatly appreciated.
**app.js**
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+"/cal.html");
});
app.post("/",function(req,res)
{
var n1=Number(req.body.num1);
var n2=Number(req.body.num2);
var n=n1+n2;
res.write("<h1>sum is" + n+"</h1>");
res.send();
})
app.listen(2000,function()
{
console.log("server is running");
});
cal.html (HTML document)
<!DOCTYPE html>
<html>
<head>
<title>server </title>
</head>
<body>
<form action="/" method="post">
<input type="text" name="num1" value=number1>
<input type="text" name="num2" placeholder="number3">
<button type="submit" name="button">calculate</button>
</form>
</body>
</html>