Render raw HTML

前端 未结 11 1171
自闭症患者
自闭症患者 2020-12-23 18:48

I want to render raw .html pages using Express 3 as follows:

server.get(\'/\', function(req, res) {
    res.render(\'login.html\');
}

11条回答
  •  伪装坚强ぢ
    2020-12-23 19:09

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

    And put your index.html to your root page, of course you could create a /views folder for example and extend returnHtml() function.

提交回复
热议问题