Skip to content

Commit

Permalink
Allow saving to BytesIO (#596)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Sep 17, 2019
1 parent 2c42e23 commit ff4fdc7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion panel/io/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ def save(panel, filename, title=None, resources=None, template=None,

html = file_html(doc, resources, title, **kwargs)
if hasattr(filename, 'write'):
filename.write(decode_utf8(html))
html = decode_utf8(html)
if isinstance(filename, io.BytesIO):
html = html.encode('utf-8')
filename.write(html)
return
with io.open(filename, mode="w", encoding="utf-8") as f:
f.write(decode_utf8(html))

0 comments on commit ff4fdc7

Please sign in to comment.