#!/usr/bin/python import cgitb cgitb.enable() import cgi form = cgi.FieldStorage() content = form['dot'].value import py, sys fn = py.path.local.make_numbered_dir('makegraph').join('graph.dot') fn.write(content) tfn = fn.new(ext='.plain') py.process.cmdexec("dot -Tplain %s >%s" %(fn, tfn)) result = tfn.read() print "Content-Type: text/plain" print sys.stdout.write(result)