我试图在'status.html'之后获得查询,如localhost:3000/status.html?channel="string that I want to get"
。尝试使用node.js中的express在app.get函数中获取查询
所以我写了下面的代码。
app.get('/status.html', isLoggedIn, function(res, req){
if (req.query.channel){
if (req.isAuthenticated()){
res.redirect('/status');
}else{
console.log("Please Log in to access to this webpage");
res.redirect('/login');
}
}
});
然而,它甚至不经过app.get '/status.html' ......
什么这里是我的问题...? 任何人都可以帮我在这里..?
谢谢
以防万一,我的目录设置如下
node_modules
public
images
javascripts
js
stylesheets
status.html
routes
views
login
app.js
package.json
谢谢你回复我! :)嗯..我看到..我已经设置并重定向到'localhost:3000/status.html'从代码和工作没有问题,所以我想我可以使用app.get('/ status.html'。 ..)的东西....:'( – paulc1111
'localhost:3000/status.html'意味着你正在静态加载一个html文件, 快看看'res.sendFile()'函数 –
Thanks :)我会看看express res.sendFile()函数:)再次感谢您的帮助! – paulc1111