forked from tiankaixie/auditing-sensitivity-graph-ranking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
61 lines (48 loc) · 1.65 KB
/
server.py
File metadata and controls
61 lines (48 loc) · 1.65 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
58
59
60
61
from flask import Flask, escape, request, json, jsonify
app = Flask(__name__)
@app.route('/')
def hello():
name = request.args.get("name", "World")
return f'Hello, {escape(name)}!'
@app.route('/perturb/', methods=['POST'])
def perturb():
"""Given ID load perturbation data
Returns: meta data in json
"""
request_raw = request.get_json()
res = {}
print("perturbing...")
with open("cached_data/" + request_raw["dataName"] + "_" + request_raw[
"algorithmName"] + "_detail_" + str(request_raw["removeID"]) +".json") as json_file:
res = json.load(json_file)
print("perturbation executed")
return jsonify(res)
@app.route('/loadData/', methods=['POST'])
def load_data():
"""Load data offline mode
Returns: meta data in json
"""
request_raw = request.get_json()
res = {}
print("load data")
with open("cached_data/" + request_raw["dataName"] + "_" + request_raw[
"algorithmName"] + "_overview.json") as json_file:
res = json.load(json_file)
print("data loaded")
return jsonify(res)
# @app.route('/loadData/', methods=['POST'])
# def load_data():
# """Load data online mode
#
# Returns: meta data in json
#
# """
# request_raw = request.get_json()
# graph_object, label_dict_set = load_data_from_text(
# data_name=request_raw["dataName"])
# meta_data = MetaData(graph_object=graph_object,
# label_dict_set=label_dict_set,
# algorithm_name=request_raw["algorithmName"])
# return json.dumps(meta_data, cls=MetaDataEncoder)
if __name__ == "__main__":
app.run(debug=True)