feat(server.tests.test5): 新增 server 实验5

This commit is contained in:
2025-11-18 13:35:30 +08:00
parent 84b4770d5a
commit d0acf5a36d
9 changed files with 1095 additions and 1 deletions

View File

@@ -0,0 +1,77 @@
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body,
html {
margin: 0;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
form {
display: flex;
flex-direction: column;
width: 280px;
gap: 12px;
text-align: center;
}
input {
padding: 8px;
font-size: 15px;
width: 100%;
box-sizing: border-box;
}
button {
padding: 10px;
font-size: 16px;
cursor: pointer;
}
</style>
<title>Login</title>
</head>
<body>
<form id="loginForm">
<input type="text" id="username" placeholder="请输入用户名">
<input type="password" id="password" placeholder="请输入密码">
<button type="button" id="loginBtn">登录</button>
</form>
<script>
document.getElementById("loginBtn").addEventListener("click", login);
async function login() {
const username = document.getElementById("username").value.trim();
const password = document.getElementById("password").value.trim();
if (!username || !password) {
alert("请输入用户名和密码");
return;
}
const res = await fetch("http://localhost:3000/login", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ username, password })
});
const data = await res.text();
alert(data);
}
</script>
</body>
</html>