我試圖在'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