html 页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>03-http_get</title>
</head>
<body>
<fieldset>
<legend><h2>HTTP_GET请求</h2></legend>
<form action="http://127.0.0.1:7799" method="get">
<input type="text" placeholder="用户名" name="username">
<input type="text" placeholder="密码" name="password">
<input type="submit">
</form>
</fieldset>
</body>
</html>
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/750eadc3ffca7a7f0f227623e73d3fcd.png)
js 页面
const http = require("http");
const url = require("url");
const fs = require("fs");
const server = http.createServer(function (req, res) {
const urlObj = url.parse(req.url, true);
if (urlObj.pathname == "/") {
res.writeHead(200, {"Content-Type":"text/plain; charset=utf-8"});
if (urlObj.query.username == "张三" && urlObj.query.password == "666") {
res.end("登录成功!");
} else {
res.end("登录失败!");
}
}else {
let readS = fs.createReadStream("favicon.ico");
readS.pipe(res);
}
});
server.listen(7799, function () {
console.log("服务器搭建完毕, listener....");
});