Node.js + Express without using Jade


Question

Is it possible to use express without any template engine?

1
42
1/13/2017 11:39:42 PM

Accepted Answer

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'));
15
9/29/2016 2:17:24 PM

Yes,

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

should just work


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon