While working with NodeJS server application, we may come to situation where we need to redirect out request to any html page and render the same html page to browser. Below is the sample code to send a html file as a response in NodeJS app.
app.get('/home', (req, res) => {res.sendFile(publicPageDire+'/index.html')})
In place of publicPageDire variable we could also use path.join() like below
app.get('/home', (req, res) => {res.sendFile(path.join(__dirname, '../public/index.html'))})