📌  相关文章
📜  app.post(' ', function (req, res) { res.send('POST request to homepage') }) - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:11.611000             🧑  作者: Mango

代码示例1
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");
})