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頁面