learning express step(十二)

learning express view engine function

const express = require('express');
const app = express();

app.set('views','./views');
app.set('view engine', 'pug');

app.get('/', function(req, res){
    res.render('index',{title: 'hey', message: 'hello panzidong using views'});
});
app.listen(3000);

views/index.pug

html
  head
    title= title
  body
    h1= message

 

result:

 

posted @ 2019-06-13 11:14  嵌入式实操  阅读(72)  评论(0编辑  收藏  举报