generated from USC-EE-250L-Spring-2023/lab-10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.py
45 lines (36 loc) · 943 Bytes
/
server.py
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
from flask import Flask, request, jsonify
from main import process1, process2
app = Flask(__name__)
@app.route('/')
def index():
return jsonify({'message': 'Welcome'})
# TODO: Create a flask app with two routes, one for each function.
# The route should get the data from the request, call the function, and return the result.
@app.route('/process1', methods=['POST'])
def p1():
"""
Summary: calls process1
Args:
data (List[int]): the data
Returns:
list: result
"""
data = request.get_json()
res = jsonify(process1(data))
res.status_code = 200
return res
@app.route('/process2', methods=['POST'])
def p2():
"""
Summary: calls process2
Args:
data (List[int]): the data
Returns:
list: result
"""
data = request.get_json()
res = jsonify(process2(data))
res.status_code = 200
return res
if __name__ == '__main__':
app.run(host="0.0.0.0", port=8000)