Below is how to do it
app.get('/', function(req, res) {
res.sendFile('index.html', { root: __dirname });
});
__dirname is a keyword which will help to get the directory name of the app that is currently running.
This way the file can be streamed as well.
References:
https://stackoverflow.com/questions/26079611/node-js-typeerror-path-must-be-absolute-or-specify-root-to-res-sendfile-failed
app.get('/', function(req, res) {
res.sendFile('index.html', { root: __dirname });
});
__dirname is a keyword which will help to get the directory name of the app that is currently running.
This way the file can be streamed as well.
References:
https://stackoverflow.com/questions/26079611/node-js-typeerror-path-must-be-absolute-or-specify-root-to-res-sendfile-failed
No comments:
Post a Comment