Add support for display_data messages in HTTP outputs
Problem
I'd like IPython.display.display to work for all the supported mime types.
Repro:
# GET /
from IPython.display import display
display({"a": 1})
Expected output:
{"a": 1}
Actual output:
(nothing)
Proposed Solution
I think adding a bit of code in the notebook handler that mimics what the notebook frontend does would be sufficient. Two places in particular
- https://github.com/jupyter-server/kernel_gateway/blob/main/kernel_gateway/notebook_http/handlers.py#L127 needs to not drop
display_data(and accumulate them appropriately) - https://github.com/jupyter-server/kernel_gateway/blob/main/kernel_gateway/notebook_http/handlers.py#L87 needs to also convert them to a reasonable result (ie presenting mimetypes appropriately for an HTML context)
Additional context
This seems like a common thing that would need to be done either by javascript frontends or python HTML-serving ones. I haven't seen if theres any code available for reuse but am curious if there is any.
I'm happy to take a stab at implementing a bit of this - PR's OK?
Seems like https://ipython.readthedocs.io/en/stable/config/integrating.html#custom-methods lists all the mime types that need to be supported