feat: add serveStatic middleware
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>V-Hono 静态文件服务 - Public 目录</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
max-width: 600px;
|
||||
margin: 50px auto;
|
||||
padding: 20px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
.container {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
padding: 30px;
|
||||
border-radius: 15px;
|
||||
backdrop-filter: blur(10px);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 { margin-bottom: 20px; font-size: 2.5em; }
|
||||
p { font-size: 1.2em; line-height: 1.6; }
|
||||
.feature {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 15px;
|
||||
margin: 10px 0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🎉 成功!</h1>
|
||||
<p>这是来自 <code>./public</code> 目录的 <code>index.html</code> 文件</p>
|
||||
|
||||
<div class="feature">
|
||||
<h3>✨ V-Hono 静态文件服务特性</h3>
|
||||
<p>✅ 自动索引文件支持</p>
|
||||
<p>✅ 路径遍历攻击防护</p>
|
||||
<p>✅ ETag 和缓存支持</p>
|
||||
<p>✅ 智能 Content-Type 检测</p>
|
||||
</div>
|
||||
|
||||
<p><a href="/" style="color: #fff; text-decoration: underline;">← 返回主页</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,9 @@
|
||||
Hello from V-Hono static file server!
|
||||
|
||||
This is a test file from the ./public directory.
|
||||
You can access this file directly via the root path (/).
|
||||
|
||||
Features demonstrated:
|
||||
- Text file serving
|
||||
- Content-Type detection
|
||||
- Path mapping from URL to file system
|
||||
Reference in New Issue
Block a user