1
0
Fork 0
mirror of https://github.com/sileht/bird-lg.git synced 2024-11-25 00:04:42 +01:00

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

5
lg.py
View file

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