-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
executable file
·43 lines (31 loc) · 1.12 KB
/
debug.py
File metadata and controls
executable file
·43 lines (31 loc) · 1.12 KB
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
# 游戏对战平台主程序入口
from app import create_app
from flask import render_template, jsonify # 添加这一行导入render_template函数
# 创建应用实例
app = create_app()
# 全局错误处理
@app.errorhandler(404)
def page_not_found(e):
return render_template("errors/404.html"), 404 # 使用导入的render_template函数
@app.errorhandler(500)
def internal_server_error(e):
return render_template("errors/500.html"), 500 # 这里也需要修改
# 健康检查端点
@app.route("/health")
def health_check():
return {"status": "ok", "service": "game-platform"}, 200
# 查看最后一次 commit 信息
@app.route("/commit-info")
def commit_info():
try:
import subprocess
result = subprocess.run(
["git", "log", "-1", "--pretty=format:%h - %an, %ad : %s"],
capture_output=True,
text=True,
)
return jsonify(commit=result.stdout.strip())
except Exception:
return "Cannot get the latest commit info"
if __name__ == "__main__":
app.run(debug=False, host="0.0.0.0", port=5000)