var express = require("express");
var bodyParser = require('body-parser');
var app = express();
var urlencodedParser = bodyParser.urlencoded({extended:false});
app.get("/index",function(req,res){
console.log(req.fresh);
res.send("Hello world");
});
app.post("/abc",urlencodedParser,function(req,res){
var response = {
first_name:req.body.a,
last_name:req.body.b
};
console.log(response);
res.end(JSON.stringify(response));
});
var server = app.listen(8081,function(){
var host = server.address().address;
var port = server.address().port;
console.log("应用实例,访问地址为 http://%s:%s",host,port);
});
express真不错