Hi,

I’m trying to use the notebook-http mode of Kernel Gateway to create an API the 
replies PDF files, but I’m not able to create a response correctly. I have 
created  a notebook with the two cells below. I published it using the 
KGateway, but if I call it, no output is received. Does anyone know a solution 
to build a response with binary data using the http-mode?

# GET /binary
import sys
from IPython.display import publish_display_data
pdf_file = "/home/jovyan/work/api/testpdf.pdf"
with open(pdf_file, 'rb') as f:
    publish_display_data({'application/pdf': f.read()})

# ResponseInfo GET /binary
import json
print(json.dumps({
        'headers' : {
            'Content-Type' : 'application/pdf'
        }
    })
)

Regards,
Eduardo

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/1AC61F64-17F5-48B1-826C-4E1494C5E0A2%40qualtera.com.

Reply via email to