Hi,
I would like to know how to reply the content of a binary file using the notebook-http mode from Jupyter Kernel Gateway.
For example, I want to publish a HTTP service that returns the PDF file. In the Python notebook, if I try to use print(content), Python adds a 'b' prefix that breaks the file (a browser can't read)
# GET /pdf
#In Python, I need to read it as binary
with open(fname_pdf, 'rb') as f:
content = f.read()
#The problem is here, Python adds 'b' prefix and this can't be processed by the browser.
print(content)
# ResponseInfo GET /pdf
print(json.dumps({
'headers' : {
'Content-Type' : 'application/pdf'
}
})
)
Regards,
Eduardo