// 创建网络服务器的模块
const http = require("http")
// app对象就是网站服务器对象
const app = http.createServer();
const queryString = require('querystring')
// 响应请求
app.on("request",(req,res)=>{
// post参数是通过事件接收的
// data 当请求参数传递的时候触发data事件
// end 当参数完成的时候触发 end 事件
let postParams = ''
req.on('data',params=>{
postParams += params
})
req.on('end',()=>{
let postparams = queryString.parse(postParams)
console.log(postparams.username);
console.log(postparams.password);
})
res.end("<h1>OK</h1>")
})
app.listen(3000);
console.log("服务器创建成功...");