Node.js + Express without using Jade

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

Is it possible to use express without any template engine?

6条回答
  •  不知归路
    2020-12-13 04:26

    For anyone having the need to immediately use regular HTML without jade in a new express project, you can do this.

    Add a index.html to the views folder.

    In app.js change

    app.get('/', routes.index);
    

    to

    app.get('/', function(req, res) {
      res.sendfile("views/index.html");
    });
    

    UPDATE

    Use this instead. See comment section below for explanation.

    app.get('/', function(req, res) {
      res.sendFile(__dirname + "/views/index.html"); 
    });
    

提交回复
热议问题