What is the right way to set path?
in my app i this code for i use set path for sending file.
app.get(\'/\',function(req, res){//get,put,post,delete
Change this
app.get('/',function(req, res){//get,put,post,delete
res.sendfile(__dirname + '/client/views/index.html');
});
to this and this should work.
app.get('/',function(req, res){//get,put,post,delete
res.sendFile(__dirname + '/client/views/index.html');
});
In new versions sendfile
has been deprecated. Change sendfile
to sendFile
.
Considering this working example:
router.get('/iso', (req, res) => {
res.sendfile('public/isofinder.html');
});
This is not so easily translated into the method call sendFile.
router.get('/iso', (req, res) => {
res.sendFile(__dirname + '/../public/isofinder.html');
});
This variation gives a 403 error (Forbidden). In this case only this solution will work:
router.get('/iso', (req, res) => {
res.sendFile('[absolute_path_to_source]/public/isofinder.html');
});
Short Answer : replace res.sendfile with res.sendFile .i will give you a example with code :
app.get("/" ,function(req,resp){
resp.sendfile(__dirname + "/index.html")})
<p>replace with this</p>
app.get("/" ,function(req,resp){
resp.sendFile(__dirname + "/index.html")})