def handle_request(self):
try:
data = urllib.unquote(self.get_argument('q'))
with tempfile.NamedTemporaryFile(suffix='.latex') as raw:
raw.write(data)
raw.flush()
filename = latex_to_dvi(raw.name)
svg_data = dvi_to_svg(filename).strip()
png_data, width, height = svg_to_png(svg_data)
png_data = png_data.strip().encode('base64')
return {
'success': True,
'svg': svg_data,
'png': png_data,
'meta': {'width': width,
'height': height}
}
except Exception as error:
print error.message
return {
'success': False,
'error': error.message
}
评论列表
文章目录