Nodejs Pug扩展

时间:2019-03-31 12:37:46

标签: javascript node.js pug

这里绝对是初学者。我只是使用node.js设置了新服务器,但卡在了哈巴狗视图上。尝试将login.pug扩展为index.pug,但是我只得到空白内容,而页脚和头部除外。我在哪里做错了?请帮助... p / s:已安装哈巴狗

SET @start = '22/03/2019';
SET @end = '24/03/2019';
select 
  date_format(date_time,'%d/%m/%Y'), 
  AVG(Total), sum(Total_ly),  
  AVG((Total + Total_ly)/2) 
from Transaction 
WHERE date_time between STR_TO_DATE(@start, '%d/%m/%Y') AND STR_TO_DATE(@end, '%d/%m/%Y') 
Group By date_time;
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

// for parsing application/json
app.use(bodyParser.json());

// for parsing application/xwww-
app.use(bodyParser.urlencoded({
    extended: true
}));
//form-urlencoded

app.get('/', function (req, res) {
    res.render('index');
});

// for parsing multipart/form-data
app.use(upload.array());
app.use(express.static('public'));

1 个答案:

答案 0 :(得分:2)

app.get('/', function (req, res) {
    res.render('index');
});

您正在获取时呈现index.pub。但是,您尚未将 login.pub 扩展到索引中。相反,您是将索引扩展到您的 login.pub

如果仅将渲染更改为登录,则应该能够看到新内容。

app.get('/', function (req, res) {
    res.render('login');
});