Node.js + Express without using Jade

前端 未结 6 1507
礼貌的吻别
礼貌的吻别 2020-12-13 04:15

Is it possible to use express without any template engine?

6条回答
  •  臣服心动
    2020-12-13 04:37

    UPDATED

    Some might have concerns that sendFile only provides client side caching. There are various ways to have server side caching and keeping inline with the OP's question one can send back just text too with send:

    res.send(cache.get(key));
    

    Below was the original answer from 3+ years ago:

    For anyone looking for an alternative answer to PavingWays, one can also do:

    app.get('/', function(req, res) {
      res.sendFile('path/to/index.html');
    });
    

    With no need to write:

    app.use(express['static'](__dirname + '/public'));
    

提交回复
热议问题