Files
golang/golang-learning/10-projects/03-web-server/static/index.html
2025-08-24 13:01:09 +08:00

101 lines
3.8 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Go Web服务器</title>
<link rel="stylesheet" href="/static/style.css">
</head>
<body>
<div class="container">
<header>
<h1>🚀 Go Web服务器</h1>
<p>一个使用Go语言编写的简单HTTP服务器示例</p>
</header>
<main>
<section class="api-section">
<h2>📚 API接口测试</h2>
<div class="api-group">
<h3>用户管理</h3>
<div class="api-item">
<button onclick="getUsers()">获取所有用户</button>
<span class="method get">GET</span>
<span class="endpoint">/api/users</span>
</div>
<div class="api-item">
<button onclick="createUser()">创建用户</button>
<span class="method post">POST</span>
<span class="endpoint">/api/users</span>
</div>
<div class="api-item">
<input type="number" id="userId" placeholder="用户ID" min="1">
<button onclick="getUser()">获取用户</button>
<span class="method get">GET</span>
<span class="endpoint">/api/users/{id}</span>
</div>
<div class="api-item">
<button onclick="deleteUser()">删除用户</button>
<span class="method delete">DELETE</span>
<span class="endpoint">/api/users/{id}</span>
</div>
</div>
<div class="api-group">
<h3>系统信息</h3>
<div class="api-item">
<button onclick="getHealth()">健康检查</button>
<span class="method get">GET</span>
<span class="endpoint">/health</span>
</div>
<div class="api-item">
<button onclick="getStats()">服务器统计</button>
<span class="method get">GET</span>
<span class="endpoint">/api/stats</span>
</div>
</div>
</section>
<section class="form-section">
<h2>📝 创建用户表单</h2>
<form id="userForm">
<div class="form-group">
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">邮箱:</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="age">年龄:</label>
<input type="number" id="age" name="age" min="0" max="150" required>
</div>
<button type="submit">创建用户</button>
</form>
</section>
<section class="response-section">
<h2>📄 响应结果</h2>
<pre id="response"></pre>
</section>
</main>
<footer>
<p>&copy; 2024 Go Web服务器示例项目</p>
</footer>
</div>
<script src="/static/script.js"></script>
</body>
</html>