【发布时间】:2021-11-28 11:21:56
【问题描述】:
我有一个服务器,里面有这样的文件:
- index.js
/client
-index.html
-about.html
-signup.html
-style.css
在 index.js 中,我有一个快速服务器。
- 当用户转到
/时,应该转到index.html - 当用户转到
/about.html时,它应该转到 about.html 等 - 当用户转到
/style.css时,它应该转到 style.css 等。
我知道你可以这样做..
app.get('/', (req, res) => {
res.sendFile(__dirname + '/client/index.html')
})
但我想让它自动发送正确的文件,而不必get每个文件夹。
我知道它与app.use 有关,但我不完全确定如何使用它。
【问题讨论】:
标签: javascript node.js express directory