diff -r dee15870206a -r ff1941c85fd3 cylindertransport-web.py --- a/cylindertransport-web.py Thu Apr 06 15:41:04 2017 +0200 +++ b/cylindertransport-web.py Thu Apr 06 16:21:21 2017 +0200 @@ -6,12 +6,14 @@ import cgi, data, json, config from cylindertransport import CylinderSpacerCalculator +import base64 +import cStringIO # enable debugging #import sys #sys.stderr = sys.stdout -#import cgitb -#cgitb.enable() +import cgitb +cgitb.enable() def do_action(args): """ @@ -21,9 +23,14 @@ cylinders = args.getlist("cylinders[]") calc = CylinderSpacerCalculator(cylinders) calc.calculate() + image = calc.render_image() + buffer = cStringIO.StringIO() + image.save(buffer, format="PNG") + img_str = base64.b64encode(buffer.getvalue()) print json.dumps({ "objects": calc.circles, - "scale3d": config.SCALE3D + "scale3d": config.SCALE3D, + "image": img_str }) else: print "unknown Action %s" % args["action"].value