Can I return my panel code as HTML?

Hi,

I wonder if I can write notebook with panel controls and then get the HTML code out of it?
I want to integrate with jupyter kernel gateway which requires me to return html type from API.

Thanks!

I think Deploy and Export — Panel 0.11.3 documentation
pane.save("test.html")

1 Like

Thanks!
is there an option to return it without saving it to file?

and another thing I tried it for this code:

@pn.depends(slider.param.value)
def callback(value):
return ‘%d * 5 = %d’ % (value, value*5)

row = pn.Row(slider, callback)
row.save(‘test.html’)

and when opening the html page any change in slider doesn’t affect the text as expected (and works in jupyter notebooks)

row.save('test.html', embed=True)

1 Like

Thanks, it makes it working but it allows user to select only 0,5,10 numbers in slider instead of every number between 0-10 as in notebook.

Read Deploy and Export — Panel 0.11.3 documentation under Embedding

1 Like

Thanks, I solved it. If there is way to get the HTML in memory instead of saving to file I will be happy to hear.

.embed() maybe

You could use something like:

from io import StringIO

st = StringIO()

obj.save(st, embed=True)

st.seek(0)

html = st.read()

(Not tested)