node.js和console.log中的连接闪存之间的区别?

问题描述:

从我的理解,都做服务器打印输出。我尝试使用下面的闪光灯,我只看到控制台打印输出。node.js和console.log中的连接闪存之间的区别?

app.get('/', function(req, res){ 
    console.log('hi there!'); 
    req.flash('info', 'flash test'); 
    req.end(); 
}); 

闪光灯用于什么以及如何使用它?

向观看您的网站的用户显示Flash消息。 console.log显示在服务器正在运行的控制台上。

connect-flash是实现Flash消息的中间件。用户下次浏览页面时,用户浏览器上会显示Flash消息。 Flash通常与重定向结合使用,以确保消息可用于要呈现的下一页。这就像是最后一页浏览的提醒。

//go to /flash page 
app.get('/flash', function(req, res){ 
    req.flash('info', 'Hi there!') 
    res.redirect('/'); 
}); 
//info message shown when user sees/home page 
+0

明白了,谢谢! – 2013-03-25 17:34:32