webStrom用node写的html页面Failed to load resource: the server responded with a status of 404 (Not Found)

webStrom 用node写的html页面

1、页面显示的错误信息,因为找不到js和css文件webStrom用node写的html页面Failed to load resource: the server responded with a status of 404 (Not Found)

2、网页点击右键检查后看console输出 显示的错误webStrom用node写的html页面Failed to load resource: the server responded with a status of 404 (Not Found)

3、控制台输出
webStrom用node写的html页面Failed to load resource: the server responded with a status of 404 (Not Found)
4、我原来把页面放到的是views目录下,就会上述的错误,当我把index.html放到public目录下后就可以正常显示页面了,但是需要把app.js里面的app.set(‘views’,path.join(__dirname, ‘/views’));改为app.set(‘views’,path.join(__dirname, ‘/public’));
webStrom用node写的html页面Failed to load resource: the server responded with a status of 404 (Not Found)

原因:express生成的框架中默认static是public

webStrom用node写的html页面Failed to load resource: the server responded with a status of 404 (Not Found)