2

I am writing a web app with jupyter-lab, ipywidgets, and voila.

In this web app, after taking instructions by the user, the notebook generates some data (a dictionary) that the user needs to download (as a .json file). The simple solution I found online is to write a file on the server with the content and provide the user with a link. However, I think this is super ugly, and very inefficient or dangerous if many users run the web app at the same time. I wonder if there is a way to create a download option for the user without writing anything on the server-side. Does anyone have some clue?

Thanks in advance, Lorenzo

1 Answers1

1

Just convert your file to be downloaded with pybase64 (file=base64.b64encode...) then ipywidgets

 HTML("<a download='name.txt' href='data:text/ascii;base64,%s'> download/>" %(file,)}
L0d0v1c
  • 31
  • 4