Spaces:
Sleeping
Sleeping
Commit ·
5ae4842
1
Parent(s): f84728a
fix check error.
Browse files- Dockerfile +1 -1
- app_flask/app_flask.py +11 -11
- static/index.html +12 -12
Dockerfile
CHANGED
|
@@ -5,7 +5,7 @@ FROM python:3.9
|
|
| 5 |
|
| 6 |
# 安装运行时依赖
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
-
gcc g++ cmake make gnupg \
|
| 9 |
nginx \
|
| 10 |
supervisor \
|
| 11 |
curl \
|
|
|
|
| 5 |
|
| 6 |
# 安装运行时依赖
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
+
gcc g++ cmake make git gnupg \
|
| 9 |
nginx \
|
| 10 |
supervisor \
|
| 11 |
curl \
|
app_flask/app_flask.py
CHANGED
|
@@ -44,6 +44,17 @@ def form():
|
|
| 44 |
<a href='./'>返回首页</a>
|
| 45 |
"""
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
'''
|
| 48 |
# 创建 RESTX API
|
| 49 |
api = Api(
|
|
@@ -76,17 +87,6 @@ tasks_db = []
|
|
| 76 |
user_counter = 1
|
| 77 |
task_counter = 1
|
| 78 |
|
| 79 |
-
# 健康检查
|
| 80 |
-
@app.route('/health', methods=['GET'])
|
| 81 |
-
def health_check():
|
| 82 |
-
return jsonify({
|
| 83 |
-
'status': 'healthy',
|
| 84 |
-
'service': 'flask',
|
| 85 |
-
'version': '1.0.0',
|
| 86 |
-
'timestamp': time.time(),
|
| 87 |
-
'environment': os.getenv('ENVIRONMENT', 'development')
|
| 88 |
-
})
|
| 89 |
-
|
| 90 |
# 根路径
|
| 91 |
@app.route('/', methods=['GET'])
|
| 92 |
def root():
|
|
|
|
| 44 |
<a href='./'>返回首页</a>
|
| 45 |
"""
|
| 46 |
|
| 47 |
+
# 健康检查
|
| 48 |
+
@app.route('/health', methods=['GET'])
|
| 49 |
+
def health_check():
|
| 50 |
+
return jsonify({
|
| 51 |
+
'status': 'healthy',
|
| 52 |
+
'service': 'flask',
|
| 53 |
+
'version': '1.0.0',
|
| 54 |
+
'timestamp': time.time(),
|
| 55 |
+
'environment': os.getenv('ENVIRONMENT', 'development')
|
| 56 |
+
})
|
| 57 |
+
|
| 58 |
'''
|
| 59 |
# 创建 RESTX API
|
| 60 |
api = Api(
|
|
|
|
| 87 |
user_counter = 1
|
| 88 |
task_counter = 1
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
# 根路径
|
| 91 |
@app.route('/', methods=['GET'])
|
| 92 |
def root():
|
static/index.html
CHANGED
|
@@ -270,20 +270,20 @@
|
|
| 270 |
<div class="endpoints">
|
| 271 |
<div class="endpoint">
|
| 272 |
<span class="method get">GET</span>
|
| 273 |
-
<span class="path">/
|
| 274 |
</div>
|
| 275 |
<div class="endpoint">
|
| 276 |
<span class="method get">GET</span>
|
| 277 |
-
<span class="path">/
|
| 278 |
</div>
|
| 279 |
<div class="endpoint">
|
| 280 |
<span class="method post">POST</span>
|
| 281 |
-
<span class="path">/
|
| 282 |
</div>
|
| 283 |
</div>
|
| 284 |
<div class="btn-group">
|
| 285 |
-
<a href="/
|
| 286 |
-
<a href="/
|
| 287 |
</div>
|
| 288 |
</div>
|
| 289 |
|
|
@@ -294,20 +294,20 @@
|
|
| 294 |
<div class="endpoints">
|
| 295 |
<div class="endpoint">
|
| 296 |
<span class="method get">GET</span>
|
| 297 |
-
<span class="path">/
|
| 298 |
</div>
|
| 299 |
<div class="endpoint">
|
| 300 |
<span class="method get">GET</span>
|
| 301 |
-
<span class="path">/
|
| 302 |
</div>
|
| 303 |
<div class="endpoint">
|
| 304 |
<span class="method post">POST</span>
|
| 305 |
-
<span class="path">/
|
| 306 |
</div>
|
| 307 |
</div>
|
| 308 |
<div class="btn-group">
|
| 309 |
-
<a href="/
|
| 310 |
-
<a href="/
|
| 311 |
</div>
|
| 312 |
</div>
|
| 313 |
</div>
|
|
@@ -365,10 +365,10 @@
|
|
| 365 |
await checkService('/health', 'nginx-status');
|
| 366 |
|
| 367 |
// 检查 FastAPI
|
| 368 |
-
await checkService('/
|
| 369 |
|
| 370 |
// 检查 Flask
|
| 371 |
-
await checkService('/
|
| 372 |
|
| 373 |
// 更新请求计数(模拟)
|
| 374 |
const currentCount = parseInt(document.getElementById('total-requests').textContent);
|
|
|
|
| 270 |
<div class="endpoints">
|
| 271 |
<div class="endpoint">
|
| 272 |
<span class="method get">GET</span>
|
| 273 |
+
<span class="path">/appfast/</span>
|
| 274 |
</div>
|
| 275 |
<div class="endpoint">
|
| 276 |
<span class="method get">GET</span>
|
| 277 |
+
<span class="path">/appfast/docs</span>
|
| 278 |
</div>
|
| 279 |
<div class="endpoint">
|
| 280 |
<span class="method post">POST</span>
|
| 281 |
+
<span class="path">/appfast/items</span>
|
| 282 |
</div>
|
| 283 |
</div>
|
| 284 |
<div class="btn-group">
|
| 285 |
+
<a href="/appfast/docs" class="btn" target="_blank">API 文档</a>
|
| 286 |
+
<a href="/appfast/health" class="btn secondary" target="_blank">服务状态</a>
|
| 287 |
</div>
|
| 288 |
</div>
|
| 289 |
|
|
|
|
| 294 |
<div class="endpoints">
|
| 295 |
<div class="endpoint">
|
| 296 |
<span class="method get">GET</span>
|
| 297 |
+
<span class="path">/appflask/</span>
|
| 298 |
</div>
|
| 299 |
<div class="endpoint">
|
| 300 |
<span class="method get">GET</span>
|
| 301 |
+
<span class="path">/appflask/docs</span>
|
| 302 |
</div>
|
| 303 |
<div class="endpoint">
|
| 304 |
<span class="method post">POST</span>
|
| 305 |
+
<span class="path">/appflask/users</span>
|
| 306 |
</div>
|
| 307 |
</div>
|
| 308 |
<div class="btn-group">
|
| 309 |
+
<a href="/appflask/docs" class="btn" target="_blank">API 文档</a>
|
| 310 |
+
<a href="/appflask/health" class="btn secondary" target="_blank">服务状态</a>
|
| 311 |
</div>
|
| 312 |
</div>
|
| 313 |
</div>
|
|
|
|
| 365 |
await checkService('/health', 'nginx-status');
|
| 366 |
|
| 367 |
// 检查 FastAPI
|
| 368 |
+
await checkService('/appfast/health', 'fastapi-status');
|
| 369 |
|
| 370 |
// 检查 Flask
|
| 371 |
+
await checkService('/appflask/health', 'flask-status');
|
| 372 |
|
| 373 |
// 更新请求计数(模拟)
|
| 374 |
const currentCount = parseInt(document.getElementById('total-requests').textContent);
|