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}`) });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter