-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (38 loc) · 1.12 KB
/
main.py
File metadata and controls
57 lines (38 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from app import create_app
from flask import render_template
# 创建应用实例
app, socketio = create_app()
# 全局错误处理
@app.errorhandler(400)
def bad_request(e):
return render_template("errors/400.html"), 400
@app.errorhandler(403)
def forbidden(e):
return render_template("errors/403.html"), 403
@app.errorhandler(404)
def page_not_found(e):
return render_template("errors/404.html"), 404
@app.errorhandler(500)
def internal_server_error(e):
return render_template("errors/500.html"), 500
@app.errorhandler(502)
def bad_gateway(e):
return render_template("errors/502.html"), 502
@app.errorhandler(503)
def service_unavailable(e):
return render_template("errors/503.html"), 503
@app.errorhandler(504)
def gateway_timeout(e):
return render_template("errors/504.html"), 504
@app.route("/health")
def health_check():
return {"status": "ok", "service": "Uniweb"}, 200
if __name__ == "__main__":
# 支持websocket
socketio.run(
app,
debug=app.config["DEBUG"],
host=app.config["HOST"],
port=app.config["PORT"],
allow_unsafe_werkzeug=True,
)