Use base64 for bgpmap

This commit is contained in:
Mehdi Abaakouk 2017-08-16 22:22:42 +02:00 committed by root
parent c01c5c765f
commit 6dfd9f7546
1 changed files with 4 additions and 1 deletions

5
lg.py
View File

@ -20,6 +20,7 @@
#
###
import base64
from datetime import datetime
import memcache
import subprocess
@ -401,6 +402,7 @@ def show_bgpmap():
if not data:
abort(400)
data = base64.b64decode(data)
data = json.loads(data)
graph = pydot.Dot('BGPMAP', graph_type='digraph')
@ -508,6 +510,7 @@ def show_bgpmap():
#response = Response("<pre>" + graph.create_dot() + "</pre>")
response = Response(graph.create_png(), mimetype='image/png')
# response = Response(graph.create_svg(), mimetype='image/svg+xml')
response.headers['Last-Modified'] = datetime.now()
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
response.headers['Pragma'] = 'no-cache'
@ -635,7 +638,7 @@ def show_route(request_type, hosts, proto):
detail[host] = add_links(res)
if bgpmap:
detail = json.dumps(detail)
detail = base64.b64encode(json.dumps(detail))
return render_template((bgpmap and 'bgpmap.html' or 'route.html'), detail=detail, command=command, expression=expression, errors=errors)