summaryrefslogtreecommitdiffstats
path: root/docker/storperf-reporting/src/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'docker/storperf-reporting/src/app.py')
-rw-r--r--docker/storperf-reporting/src/app.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/docker/storperf-reporting/src/app.py b/docker/storperf-reporting/src/app.py
index 62d4d33..74d1339 100644
--- a/docker/storperf-reporting/src/app.py
+++ b/docker/storperf-reporting/src/app.py
@@ -10,17 +10,38 @@
from flask import Flask, redirect, url_for, request, render_template, session
from flask import send_from_directory, flash
import urllib
+import validators
import json
app = Flask(__name__)
app.secret_key = 'storperf_graphing_module'
+def get_data(data):
+ metrics = {}
+ report_data = {}
+ temp = data.keys()[0]
+ if type(data[temp]) is list:
+ details = data[temp][0].get('details')
+ metrics = details.get('metrics')
+ report_data = details.get('report_data')
+ else:
+ metrics = data[temp].get('metrics')
+ report_data = data[temp].get('report_data')
+ return metrics, report_data
+
+
@app.route('/reporting/success/')
def success():
try:
- data = urllib.urlopen(session["url"]).read()
+ URL = session["url"]
+ if validators.url(URL):
+ data = urllib.urlopen(URL).read()
+ else:
+ data = open("./static/testdata/" + URL).read()
data = json.loads(data)
- return render_template('plot_tables.html', data=data)
+ metrics, report_data = get_data(data)
+ return render_template('plot_tables.html',
+ metrics=metrics, report_data=report_data)
except Exception as e:
session['server_error'] = e.message + ' ' + repr(e.args)
return redirect(url_for('file_not_found'))