Node.js + Express不使用Jade [英] Node.js + Express without using Jade

查看:228
本文介绍了Node.js + Express不使用Jade的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

UPDATED



有些人可能会担心 sendFile 只提供客户端缓存。有多种方法可以让服务器端缓存并保持与OP的问题保持一致,也可以使用发送

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

以下是3年以前的原始答案:



对于寻找PavingWays的替代答案的人,还可以:

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

无需写:

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


Is it possible to use express without any template engine?

解决方案

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

这篇关于Node.js + Express不使用Jade的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆