Feat: 代码提交

This commit is contained in:
2026-03-30 22:05:57 +08:00
parent b2031452c4
commit 6ea70691c9
21 changed files with 3168 additions and 0 deletions
+112
View File
@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>404 - 页面未找到</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.error-container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
max-width: 500px;
padding: 50px;
text-align: center;
}
.error-code {
font-size: 120px;
font-weight: bold;
color: #e74c3c;
line-height: 1;
margin-bottom: 10px;
}
.error-title {
font-size: 28px;
color: #333;
margin-bottom: 15px;
}
.error-message {
color: #666;
font-size: 16px;
line-height: 1.6;
margin-bottom: 30px;
}
.error-animation {
font-size: 60px;
margin-bottom: 20px;
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0%, 100% {
transform: translateY(0px);
}
50% {
transform: translateY(-20px);
}
}
.btn {
display: inline-block;
padding: 12px 30px;
font-size: 16px;
font-weight: 600;
text-decoration: none;
border-radius: 8px;
transition: all 0.3s ease;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
cursor: pointer;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.footer {
margin-top: 30px;
color: #999;
font-size: 14px;
}
</style>
</head>
<body>
<div class="error-container">
<div class="error-animation">🔍</div>
<div class="error-code">404</div>
<div class="error-title">页面未找到</div>
<p class="error-message">
您访问的页面可能已被删除、移动或暂时不可用。<br>
请检查URL是否正确或返回首页。
</p>
<a href="/" class="btn">返回首页</a>
<div class="footer">
<p>Simple Web Server - HTTP 404 Not Found</p>
</div>
</div>
</body>
</html>
+151
View File
@@ -0,0 +1,151 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>501 - 方法未实现</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.error-container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
max-width: 500px;
padding: 50px;
text-align: center;
}
.error-code {
font-size: 120px;
font-weight: bold;
color: #f39c12;
line-height: 1;
margin-bottom: 10px;
}
.error-title {
font-size: 28px;
color: #333;
margin-bottom: 15px;
}
.error-message {
color: #666;
font-size: 16px;
line-height: 1.6;
margin-bottom: 30px;
}
.error-animation {
font-size: 60px;
margin-bottom: 20px;
animation: shake 0.5s ease-in-out infinite;
}
@keyframes shake {
0%, 100% {
transform: translateX(0);
}
25% {
transform: translateX(-5px);
}
75% {
transform: translateX(5px);
}
}
.btn {
display: inline-block;
padding: 12px 30px;
font-size: 16px;
font-weight: 600;
text-decoration: none;
border-radius: 8px;
transition: all 0.3s ease;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
cursor: pointer;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.supported-methods {
background: #f8f9fa;
border-radius: 8px;
padding: 20px;
margin: 20px 0;
text-align: left;
}
.supported-methods h3 {
color: #667eea;
font-size: 18px;
margin-bottom: 10px;
}
.method-badges {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.method-badge {
padding: 8px 15px;
background: #27ae60;
color: white;
border-radius: 4px;
font-weight: bold;
font-size: 14px;
}
.footer {
margin-top: 30px;
color: #999;
font-size: 14px;
}
</style>
</head>
<body>
<div class="error-container">
<div class="error-animation">⚙️</div>
<div class="error-code">501</div>
<div class="error-title">方法未实现</div>
<p class="error-message">
您使用的HTTP请求方法在当前服务器上未实现。<br>
本服务器仅支持 GET 方法。
</p>
<div class="supported-methods">
<h3>✅ 支持的请求方法</h3>
<div class="method-badges">
<span class="method-badge">GET</span>
</div>
</div>
<a href="/" class="btn">返回首页</a>
<div class="footer">
<p>Simple Web Server - HTTP 501 Not Implemented</p>
</div>
</div>
</body>
</html>
+167
View File
@@ -0,0 +1,167 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>简易Web服务器 - 欢迎</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
}
.container {
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
max-width: 600px;
width: 100%;
padding: 50px;
text-align: center;
}
h1 {
color: #333;
font-size: 36px;
margin-bottom: 10px;
}
.subtitle {
color: #666;
font-size: 18px;
margin-bottom: 30px;
}
.info-box {
background: #f8f9fa;
border-radius: 10px;
padding: 20px;
margin: 20px 0;
text-align: left;
}
.info-box h2 {
color: #667eea;
font-size: 20px;
margin-bottom: 15px;
}
.info-box ul {
list-style: none;
padding-left: 0;
}
.info-box li {
padding: 8px 0;
color: #555;
border-bottom: 1px solid #e9ecef;
}
.info-box li:last-child {
border-bottom: none;
}
.info-box li strong {
color: #333;
}
.actions {
margin-top: 30px;
}
.btn {
display: inline-block;
padding: 12px 30px;
margin: 5px;
font-size: 16px;
font-weight: 600;
text-decoration: none;
border-radius: 8px;
transition: all 0.3s ease;
border: none;
cursor: pointer;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.btn-secondary {
background: #f8f9fa;
color: #667eea;
border: 2px solid #667eea;
}
.btn-secondary:hover {
background: #667eea;
color: white;
transform: translateY(-2px);
}
.footer {
margin-top: 30px;
color: #999;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>🎉 欢迎使用简易Web服务器</h1>
<p class="subtitle">一个简单高效的多线程Web服务器</p>
<div class="info-box">
<h2>✨ 特性</h2>
<ul>
<li><strong>多线程并发</strong>:使用goroutine处理并发请求</li>
<li><strong>GET方法支持</strong>:完美的HTTP GET请求处理</li>
<li><strong>自动MIME类型</strong>:智能识别文件类型</li>
<li><strong>自定义错误页</strong>:友好的404和501错误页面</li>
<li><strong>实时日志</strong>:控制台输出访问日志</li>
<li><strong>Web管理控制台</strong>:图形化界面管理服务器</li>
</ul>
</div>
<div class="info-box">
<h2>📊 服务器信息</h2>
<ul>
<li><strong>HTTP版本</strong>:HTTP/1.1</li>
<li><strong>支持的请求方法</strong>:GET(获取)</li>
<li><strong>响应状态码</strong>:
<ul style="margin-top: 5px; margin-left: 20px;">
<li>200 OK(成功)- 请求成功</li>
<li>404 Not Found(未找到)- 资源不存在</li>
<li>501 Not Implemented(未实现)- 不支持的请求方法</li>
</ul>
</li>
</ul>
</div>
<div class="actions">
<a href="/test.html" class="btn btn-primary">测试页面</a>
<a href="http://localhost:9001" target="_blank" class="btn btn-secondary">管理控制台</a>
</div>
<div class="footer">
<p>计算机网络课程设计 | 简单Web服务器</p>
</div>
</div>
</body>
</html>
+187
View File
@@ -0,0 +1,187 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>测试页面 - Simple Web Server</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 40px 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
padding: 40px;
}
h1 {
color: #333;
font-size: 32px;
margin-bottom: 10px;
}
.subtitle {
color: #666;
font-size: 16px;
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 2px solid #f0f0f0;
}
.test-section {
margin: 30px 0;
padding: 25px;
background: #f8f9fa;
border-radius: 10px;
border-left: 4px solid #667eea;
}
.test-section h2 {
color: #667eea;
font-size: 20px;
margin-bottom: 15px;
}
.result {
font-family: 'Courier New', monospace;
background: white;
padding: 15px;
border-radius: 8px;
margin-top: 10px;
font-size: 14px;
color: #333;
}
.success {
color: #27ae60;
font-weight: bold;
}
.btn {
display: inline-block;
padding: 10px 25px;
margin: 5px;
font-size: 14px;
font-weight: 600;
text-decoration: none;
border-radius: 6px;
transition: all 0.3s ease;
border: none;
cursor: pointer;
}
.btn-primary {
background: #667eea;
color: white;
}
.btn-primary:hover {
background: #5568d3;
transform: translateY(-2px);
}
.btn-warning {
background: #f39c12;
color: white;
}
.btn-warning:hover {
background: #e67e22;
transform: translateY(-2px);
}
.footer {
text-align: center;
margin-top: 30px;
color: #999;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>🧪 功能测试页面</h1>
<p class="subtitle">测试Web服务器的各项功能</p>
<div class="test-section">
<h2>✅ 基本功能测试</h2>
<p>如果页面正常加载,说明<span class="success">GET方法处理正常</span>。</p>
<div class="result">
状态:成功加载页面 ✓<br>
时间:<span id="load-time">计算中...</span>
</div>
</div>
<div class="test-section">
<h2>📝 图片资源测试</h2>
<p>测试静态资源文件加载能力</p>
<div class="result">
<img src="../../NoteBook/img/image.png">
</div>
</div>
<div class="test-section">
<h2>🚫 错误页面测试</h2>
<p>点击下方按钮测试错误页面</p>
<button onclick="test404()" class="btn btn-warning">测试404错误</button>
<button onclick="test501()" class="btn btn-warning">测试501错误</button>
</div>
<div class="test-section">
<h2>📊 请求 Headers</h2>
<p>当前请求的头部信息:</p>
<div class="result" id="headers">加载中...</div>
</div>
<div class="footer">
<p>Simple Web Server Test Page</p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const loadTime = performance.now();
document.getElementById('load-time').textContent = loadTime.toFixed(2) + 'ms';
const headers = document.getElementById('headers');
let headerText = '';
headerText += 'User-Agent: ' + navigator.userAgent + '<br>';
headerText += 'Language: ' + navigator.language + '<br>';
headerText += 'Platform: ' + navigator.platform + '<br>';
headerText += 'Cookie Enabled: ' + navigator.cookieEnabled;
headers.innerHTML = headerText;
});
function test404() {
window.location.href = '/this-page-does-not-exist.html';
}
function test501() {
const xhr = new XMLHttpRequest();
xhr.open('POST', '/test-post', true);
xhr.onload = function() {
alert('Response Status: ' + xhr.status);
if (xhr.status === 501) {
alert('✓ 501 Not Implemented - POST is not supported');
}
};
xhr.send();
}
</script>
</body>
</html>