Spaces:
Sleeping
Sleeping
File size: 12,080 Bytes
399c9c5 5d369bb 399c9c5 5d369bb 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5d369bb 399c9c5 5d369bb 399c9c5 5d369bb 399c9c5 5ae4842 399c9c5 5ae4842 399c9c5 5d369bb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | <!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>多服务管理平台</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
line-height: 1.6;
color: #333;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
.header {
text-align: center;
margin-bottom: 3rem;
color: white;
}
.header h1 {
font-size: 3rem;
margin-bottom: 1rem;
text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}
.header p {
font-size: 1.2rem;
opacity: 0.9;
}
.services-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 2rem;
margin-bottom: 3rem;
}
.service-card {
background: white;
border-radius: 15px;
padding: 2rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.service-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}
.service-card h2 {
color: #667eea;
margin-bottom: 1rem;
font-size: 1.8rem;
}
.service-card p {
color: #666;
margin-bottom: 1.5rem;
}
.endpoints {
background: #f8f9fa;
border-radius: 8px;
padding: 1rem;
margin-top: 1rem;
}
.endpoint {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem;
border-bottom: 1px solid #e9ecef;
}
.endpoint:last-child {
border-bottom: none;
}
.method {
padding: 0.25rem 0.75rem;
border-radius: 4px;
font-size: 0.85rem;
font-weight: bold;
}
.method.get {
background: #d4edda;
color: #155724;
}
.method.post {
background: #d1ecf1;
color: #0c5460;
}
.method.put {
background: #fff3cd;
color: #856404;
}
.method.delete {
background: #f8d7da;
color: #721c24;
}
.path {
font-family: 'Courier New', monospace;
color: #495057;
}
.btn {
display: inline-block;
padding: 0.75rem 1.5rem;
background: #667eea;
color: white;
text-decoration: none;
border-radius: 8px;
font-weight: bold;
transition: background 0.3s ease;
border: none;
cursor: pointer;
font-size: 1rem;
}
.btn:hover {
background: #5a67d8;
}
.btn.secondary {
background: #48bb78;
}
.btn.secondary:hover {
background: #38a169;
}
.btn-group {
display: flex;
gap: 1rem;
margin-top: 1rem;
}
.status {
display: inline-block;
padding: 0.25rem 0.75rem;
border-radius: 20px;
font-size: 0.85rem;
font-weight: bold;
margin-bottom: 1rem;
}
.status.healthy {
background: #d4edda;
color: #155724;
}
.status.unhealthy {
background: #f8d7da;
color: #721c24;
}
.monitoring {
background: white;
border-radius: 15px;
padding: 2rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.monitoring h2 {
color: #667eea;
margin-bottom: 1.5rem;
font-size: 1.8rem;
}
.status-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
margin-bottom: 2rem;
}
.status-item {
text-align: center;
padding: 1rem;
background: #f8f9fa;
border-radius: 8px;
}
.status-item h3 {
color: #495057;
margin-bottom: 0.5rem;
font-size: 1rem;
}
.status-value {
font-size: 1.5rem;
font-weight: bold;
color: #667eea;
}
.footer {
text-align: center;
margin-top: 3rem;
color: white;
opacity: 0.8;
}
@media (max-width: 768px) {
.container {
padding: 1rem;
}
.header h1 {
font-size: 2rem;
}
.services-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🚀 多服务管理平台</h1>
<p>使用 Supervisor 管理的 Nginx + FastAPI + Flask 集成服务</p>
</div>
<div class="services-grid">
<div class="service-card">
<div class="status healthy">运行中</div>
<h2>🌐 Nginx 反向代理</h2>
<p>高性能 Web 服务器和反向代理,监听 7860 端口,负责请求路由和负载均衡。</p>
<div class="endpoints">
<div class="endpoint">
<span class="method get">GET</span>
<span class="path">/</span>
</div>
<div class="endpoint">
<span class="method get">GET</span>
<span class="path">/health</span>
</div>
</div>
<div class="btn-group">
<a href="/health" class="btn" target="_blank">健康检查</a>
</div>
</div>
<div class="service-card">
<div class="status healthy">运行中</div>
<h2>⚡ FastAPI 服务</h2>
<p>现代、高性能的 Python Web 框架,提供自动 API 文档和异步支持。</p>
<div class="endpoints">
<div class="endpoint">
<span class="method get">GET</span>
<span class="path">/appfast/</span>
</div>
<div class="endpoint">
<span class="method get">GET</span>
<span class="path">/appfast/docs</span>
</div>
<div class="endpoint">
<span class="method post">POST</span>
<span class="path">/appfast/items</span>
</div>
</div>
<div class="btn-group">
<a href="/appfast/docs" class="btn" target="_blank">API 文档</a>
<a href="/appfast/health" class="btn secondary" target="_blank">服务状态</a>
</div>
</div>
<div class="service-card">
<div class="status healthy">运行中</div>
<h2>🔧 Flask 服务</h2>
<p>轻量级、灵活的 Python Web 框架,适合构建 RESTful API 和 Web 应用。</p>
<div class="endpoints">
<div class="endpoint">
<span class="method get">GET</span>
<span class="path">/appflask/</span>
</div>
<div class="endpoint">
<span class="method get">GET</span>
<span class="path">/appflask/docs</span>
</div>
<div class="endpoint">
<span class="method post">POST</span>
<span class="path">/appflask/users</span>
</div>
</div>
<div class="btn-group">
<a href="/appflask/docs" class="btn" target="_blank">API 文档</a>
<a href="/appflask/health" class="btn secondary" target="_blank">服务状态</a>
</div>
</div>
</div>
<div class="monitoring">
<h2>📊 服务监控</h2>
<div class="status-grid">
<div class="status-item">
<h3>Nginx 状态</h3>
<div class="status-value" id="nginx-status">检查中...</div>
</div>
<div class="status-item">
<h3>FastAPI 状态</h3>
<div class="status-value" id="fastapi-status">检查中...</div>
</div>
<div class="status-item">
<h3>Flask 状态</h3>
<div class="status-value" id="flask-status">检查中...</div>
</div>
<div class="status-item">
<h3>总请求数</h3>
<div class="status-value" id="total-requests">0</div>
</div>
</div>
<button class="btn" onclick="checkAllServices()">刷新状态</button>
</div>
<div class="footer">
<p>© 2024 多服务管理平台 | 基于 Supervisor + Nginx + FastAPI + Flask</p>
<p>部署于 Hugging Face Spaces | 端口: 7860</p>
</div>
</div>
<script>
async function checkService(url, elementId) {
try {
const response = await fetch(url);
if (response.ok) {
const data = await response.json();
document.getElementById(elementId).innerHTML =
`<span style="color: #38a169;">健康 ✓</span>`;
return true;
} else {
throw new Error('服务异常');
}
} catch (error) {
document.getElementById(elementId).innerHTML =
`<span style="color: #e53e3e;">异常 ✗</span>`;
return false;
}
}
async function checkAllServices() {
// 检查 Nginx
await checkService('/health', 'nginx-status');
// 检查 FastAPI
await checkService('/appfast/health', 'fastapi-status');
// 检查 Flask
await checkService('/appflask/health', 'flask-status');
// 更新请求计数(模拟)
const currentCount = parseInt(document.getElementById('total-requests').textContent);
document.getElementById('total-requests').textContent = currentCount + 1;
}
// 页面加载时检查服务状态
document.addEventListener('DOMContentLoaded', () => {
checkAllServices();
// 每30秒自动检查一次
setInterval(checkAllServices, 30000);
});
</script>
</body>
</html> |