-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
53 lines (43 loc) · 1.09 KB
/
server.py
File metadata and controls
53 lines (43 loc) · 1.09 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
##>> Test
import os
import sys
sys.path.append(os.getcwd())
##<< Test
## <<Base>>
## <<Third-Part>>
from backend.src.platform.platform_dispatcher import PlatformDispatcher
from flask import Flask, request, jsonify, render_template
platform_dispatcher = PlatformDispatcher()
app = Flask(__name__, static_folder='./frontend/src/static', template_folder='./frontend/src/templates')
##
## handle the request from the client
##
@app.route('/', methods=['POST'])
def process_request():
try:
##
## get request from the client
##
platform_dispatcher.dispatch(request.json)
except Exception as e:
print(f"ERROR: {e}")
##
## response to the client
##
return jsonify({"message": f"request 处理失败"}), 500
##
## response to the client
##
return jsonify({"message": f"request 已开始处理"}), 200
@app.route('/', methods=['GET'])
def index():
return render_template('index.html')
if __name__ == '__main__':
##
## register platform_dispatcher
##
platform_dispatcher.register()
##
## 启动服务
##
app.run(debug=True, host='0.0.0.0', port=5000)