20 process some actions (like JSON requests) |
20 process some actions (like JSON requests) |
21 """ |
21 """ |
22 if args["action"].value == "calculate": |
22 if args["action"].value == "calculate": |
23 cylinders = args.getlist("cylinders[]") |
23 cylinders = args.getlist("cylinders[]") |
24 calc = CylinderSpacerCalculator(cylinders) |
24 calc = CylinderSpacerCalculator(cylinders) |
25 calc.calculate() |
25 # Bug... Calculate gets called by render_image, producing double circles list |
|
26 #calc.calculate() |
26 image = calc.render_image() |
27 image = calc.render_image() |
27 buffer = cStringIO.StringIO() |
28 buffer = cStringIO.StringIO() |
28 image.save(buffer, format="PNG") |
29 image.save(buffer, format="PNG") |
29 img_str = base64.b64encode(buffer.getvalue()) |
30 img_str = base64.b64encode(buffer.getvalue()) |
30 print json.dumps({ |
31 print json.dumps({ |