Loading basic HTML in Node.js

后端 未结 20 1336
暗喜
暗喜 2020-11-28 17:34

I\'m trying to find out how to load and render a basic HTML file so I don\'t have to write code like:

response.write(\'...

blahblahblah

...\
20条回答
  •  攒了一身酷
    2020-11-28 18:18

    use ejs instead of jade

    npm install ejs

    app.js

    app.engine('html', require('ejs').renderFile);
    app.set('view engine', 'html');
    

    ./routes/index.js

    exports.index = function(req, res){
    res.render('index', { title: 'ejs' });};
    

提交回复
热议问题