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