File Response with http-mode on Kernel Gateway

10 views
Skip to first unread message

Eduardo De Castro

unread,
Aug 1, 2019, 8:04:40 AM8/1/19
to jup...@googlegroups.com

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

Reply all
Reply to author
Forward
0 new messages