@blueprint.route('/export', methods=["POST"])
def export():
    svg_xml = request.form.get("data", "Invalid data")
    input_file = tempfile.NamedTemporaryFile(delete=False)
    input_file.write(svg_xml)
    input_file.close()
    filename = request.form.get("filename", "pybamview_snapshot.pdf")
    output_file_name = os.path.join("/tmp", filename)
    cmd = "rsvg-convert -o %s -f pdf %s"%(output_file_name, input_file.name)
    retcode = os.system(cmd)
    if retcode != 0:
        message("Error exporting to PDF. Is rsvg-convert installed?", "warning")
    if os.path.exists(output_file_name):
        pdf_data = open(output_file_name, "r").read()
    else: pdf_data = ""
    response = Response(pdf_data, mimetype="application/x-pdf")
    response.headers["Content-Disposition"] = "attachment; filename=%s"%filename
    return response
dataset/ETHPy150Open mgymrek/pybamview/pybamview/browser/views.py/export/original