[英]error in sendFile HTML file in express.js
I am triying yo show a file HTML with expressjs with a static __dirname but doasnt show the html after calling localhost/ 我正在尝试用静态__dirname显示带有expressjs的文件HTML,但是在调用localhost /之后不显示html
var express= require('express'); var web=express(); web.use(express.static(__dirname+'/shalimar')); //Inside /shalimar is located 'home.html' web.get('/',(req,res)=>{ console.log("Estoy Cargando desde '/'"); res.sendFile('home.html'); }); web.listen(4200,function(){ console.log('Servidor Web Iniciado en el Puerto : 4200') });
the console show e this error 控制台显示此错误
TypeError: path must be absolute or specify root to res.sendFile
How is the correct way to send an html file to local side? 如何将html文件发送到本地的正确方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.