【发布时间】:2021-08-12 06:52:10
【问题描述】:
我正在尝试使用 res.sendFile 呈现 index.html,但我不太清楚这些路径是如何工作的。我在运行它时不断收到 "Cannot GET /"。我以前可以正常工作,但我移动了文件和文件夹,这次我没有找到成功的方法。
index.js 中的代码:
const options = {root: path.join(__dirname, "/screens/")};
app.get('/', function (req, res) {
res.sendFile('index.html',options);
});
这是文件的排列方式:(我要渲染的 index.html 是屏幕文件夹中的那个)
非常感谢!
【问题讨论】: