def netdiag_image(): if request.method == 'POST': source = request.form['src'] else: source = request.args.get('src') encoding = request.args.get('encoding') if encoding == 'base64': source = base64_decode(source) svg = netdiag_generate_image(source) if encoding == 'jsonp': callback = request.args.get('callback') if callback and svg: json = simplejson.dumps({'image': svg}, ensure_ascii=False) jsonp = u'%s(%s)' % (callback, json) else: jsonp = '' response = make_response(jsonp) response.headers['Content-Type'] = 'text/javascript' else: response = make_response(svg) if encoding == 'base64': response.headers['Content-Type'] = 'image/svg+xml' else: response.headers['Content-Type'] = 'text/plain' return response
def seqdiag_image(): if request.method == "POST": source = request.form["src"] else: source = request.args.get("src") encoding = request.args.get("encoding") if encoding == "base64": source = base64_decode(source) image = seqdiag_generate_image(source) if encoding == "jsonp": callback = request.args.get("callback") if callback: json = simplejson.dumps(image, ensure_ascii=False) jsonp = u"%s(%s)" % (callback, json) else: jsonp = "" response = make_response(jsonp) response.headers["Content-Type"] = "text/javascript" else: response = make_response(image["image"]) if encoding == "base64": response.headers["Content-Type"] = "image/svg+xml" else: response.headers["Content-Type"] = "text/plain" return response
def blockdiag_generate(): if request.method == "POST": source = request.form["src"] else: source = request.args.get("src") # encoding = request.args.get('encoding') source = base64_decode(source) image = blockdiag_generate_image(source, format="PNG") response = make_response(image["image"]) response.headers["Content-Type"] = "image/png" return response
def graphviz_index(): kwargs = {} url = get_redirect_url('graphviz', request) if url: return redirect(url) source = request.args.get('src') if source: kwargs['diagram'] = base64_decode(source) body = render_template('graphviz.html', **kwargs) response = make_response(body) response.headers['Content-Type'] = 'application/xhtml+xml' return response
def nwdiag_index(): import nwdiag kwargs = {'version': nwdiag.__version__} url = get_redirect_url('nwdiag', request) if url: return redirect(url) source = request.args.get('src') if source: kwargs['diagram'] = base64_decode(source) body = render_template('nwdiag.html', **kwargs) response = make_response(body) response.headers['Content-Type'] = 'application/xhtml+xml' return response
def seqdiag_index(): import seqdiag kwargs = {"version": seqdiag.__version__} url = get_redirect_url("seqdiag", request) if url: return redirect(url) source = request.args.get("src") if source: kwargs["diagram"] = base64_decode(source) body = render_template("seqdiag.html", **kwargs) response = make_response(body) response.headers["Content-Type"] = "application/xhtml+xml" return response