多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## get数据的接收和解析 ~~~ <form action="http://localhost:8081/" method="get"> <p>用户名<input type="text" name="user"></p> <p>密码<input type="password" name="pwd"></p> <p><input type="submit"></p> </form> ~~~ ~~~ const http = require('http'); const urlLib = require("url"); http.createServer((req, res) => { let get = {} get = urlLib.parse(req.url, true).query; if(Object.keys(get).length!=0){ //获取用户名密码 console.log(get) } res.write("hello world"); res.end() }).listen(8081) ~~~ ## 假设服务器上的user:"cheng",密码为123 ~~~ const http = require('http'); const urlLib = require("url"); http.createServer((req, res) => { let get = {} get = urlLib.parse(req.url, true).query; if(Object.keys(get).length!=0){ /* 假设客户端的用户名是cheng,密码123 */ if(get.user=="cheng"&&get.pwd=="123"){ res.write("hello world"); }else{ res.write("404") } res.end() } }).listen(8081) ~~~