express post
Tue Jun 13 2023 05:36:06 GMT+0000 (Coordinated Universal Time)
Saved by
@danishyt96
#javascript
const expres = require("express");
const app = expres();
const path = require("path");
const bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({extended: false}));
app.get("/",(req, res) =>{
res.sendFile(path.join(__dirname + "/index.html"));
})
app.post("/data", (req, res) =>{
const userName = req.body.name;
const email = req.body.email;
const sum = userName+ " " + email;
res.send(sum);
});
const PORT = 4000;
app.listen(PORT, () =>{
console.log(`Server is working on ${PORT}`)
});
content_copyCOPY
Comments