const http = require(‘http‘) const url = require(‘url‘) const querystring = require(‘querystring‘) http.createServer((require,response)=>{ // GET请求 let {pathname,query}=url.parse(require.url,true) console.log(pathname,query) // POST请求 let result = [] require.on(‘data‘, (buffer) => { result.push(buffer) }) require.on(‘end‘, () => { let data = Buffer.concat(result).toString// toString是因为已知是接收帐号密码 console.log(querystring.parse(data)) }) }).listen(8080)
原文地址:https://www.cnblogs.com/foreversimon/p/12215567.html
时间: 2024-11-15 10:02:52