4 # Copyright 2019 AT&T Intellectual Property
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 from flask import Flask, jsonify, request
27 @app.route('/a1ric/metrics', methods=['GET'])
29 with open('metrics.json') as json_file:
30 metrics = json.load(json_file)
31 return jsonify(metrics)
33 @app.route('/a1ric/delay', methods=['GET'])
35 with open('delay.json') as json_file:
36 delay = json.load(json_file)
39 @app.route('/a1ric/load', methods=['GET'])
41 with open('load.json') as json_file:
42 load = json.load(json_file)
45 @app.route('/a1ric/delay', methods=['PUT'])
46 def write_delay_file():
47 if not request.json or not 'delay' in request.json:
50 'delay': request.json['delay'],
52 delay_json = json.dumps(delay)
53 f = open("delay.json","w")
55 return jsonify(delay), 201
57 @app.route('/a1ric/load', methods=['PUT'])
58 def write_load_file():
59 if not request.json or not 'load' in request.json:
62 'load': request.json['load'],
64 load_json = json.dumps(load)
65 f = open("load.json","w")
67 return jsonify(load), 201
69 if __name__ == '__main__':
70 app.run(debug=True, host='0.0.0.0', port=10080)