nodejs Express html

当我使用Express框架时,我把我的“.html”文件放到文件夹视图中,然后把“.js”和“.css”文件公开。当我运行我的应用程序时,我可以得到js和css,没有得到articlecontent.html。以下是我的网页index.html。

<div class="nav-collapse"> <ul class="nav"> <li><a href="#">Home</a></li> <li class="active"><a href="articlecontent.html" target="home">Content</a></li> </ul> <div id="container" class="container" style="height: inherit"> <iframe id="home" name="home" scrolling="no">content</iframe> </div> </div> app.get("/",function index(req,res){ res.render("index.html"); }); 

views文件夹通常用于存储模板文件; 换句话说,该文件夹包含使用res.render()发送的文件。

如果你想提供一个非模板HTML文件,比如你的articlecontent.html ,你应该把它放在公共文件夹中,这样它就会被express.static中间件服务( index.html :如果你不要求它由模板引擎呈现,也可以将其移动到公用文件夹中)。