Node.js + Express without using Jade Node.js + Express without using Jade express express

Node.js + Express without using Jade


Yes,

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

should just work


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'));


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"); });