0
const express = require('express');
const app = express();
var path = require('path');
app.get('/', function(req,res){
res.sendFile(path.join(__dirname+'/login.html'));
});
app.get('/views', function(req,res){
res.sendFile(path.join(__dirname+'/views/index.html'));
});
// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT,() => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});
// [END app]
呈现login.html的作品没有任何问题。我在我的视图目录中有index.html,并且很难渲染index.html。我知道应该使用app.use的地方,我已经尝试过,但我不知道如何使这个工作正常,所以当我输入localhost:8080/views,index.html应该弹出正确的一切工作在视图文件夹中如何使用node.js快速呈现特定路径下的某个特定路径的html页面