我無法理解如何在nodejs中使用後。我明白得到主要是用來渲染一個頁面。但是,這個示例應用程序中的後期工作如何?如何在nodejs中使用post?
var express = require("express");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/',function(req,res){
res.sendfile("index.html");
});
app.post('/login',function(req,res){
var user_name=req.body.user;
var password=req.body.password;
console.log("User name = "+user_name+", password is "+password);
res.end("yes");
});
app.listen(3000,function(){
console.log("Started on PORT 3000");
})
這裏是發送到localhost:3000/login的數據?
如果是這樣,爲什麼我會得到一個404網絡錯誤當我去這個網址時無法獲取/登錄?
究竟發生了什麼?請解釋。