//post数据提交方式=>数据接收【接收到的数据收字符串数据】
const http=require("http"); //用于创建服务
const queryString=require("querystring"); //用于post数据提交方式的数据接收【对字符串数据进行处理】 queryString.parse():将字符串数据转换为对象
http.createServer(function(request,response){ //http.createServer():创建服务 request:请求。response:响应。
if(request.url!="/favicon.ico"){ //request.url:数据请求地址
var dataString=""; //字符串数据【用于接收数据的字符串】
request.on("data",function(data){ //data事件:分段接收数据,有多少段数据发送就触发多少次。 ==>数据接收【接受到的数据是字符串】
dataString+=data; //数据累加
});
request.on("end",function(){ //end事件:接收数据完毕触发一次 ==>数据处理
console.log(queryString.parse(dataString)); //queryString.parse():将字符串数据转换为对象
response.end(); //response.end():结束【一般在数据处理完毕后结束】
});
}
}).listen(8080); //listen():端口监听