google / mesop

Rapidly build AI apps in Python
https://google.github.io/mesop/
Apache License 2.0
5.61k stars 267 forks source link

Is there a downloader? #998

Open ml2s opened 1 month ago

ml2s commented 1 month ago

Is your feature request related to a problem? Please describe. I have a need to export output table/dataframe to a spreadsheet for a user to download

Describe the solution you'd like Just like the "Uploader" component, when user clicks, a file explorer pops up to choose a folder/file to save.

Describe alternatives you've considered Not sure if the "Link" component would work as a downloader?

Additional context No.

richard-to commented 1 month ago

Right now there is no clean way to do this. But it is not impossible to do I think.

Easiest option may be to use a data url with the me.html component (See https://github.com/google/mesop/discussions/453)

Drawback here is that it's not going to be great if the file is huge. Also you have less control over styling with me.html, though you can try embedding your own stylesheet.


There is also another way, which is to mount a Fast API server with Mesop. You can then use expose a download link via Fast API. This will require saving the data you want the user to download on the file system / database / cloud storage. Then having your Fast API endpoint retrieve that file from the file system / database / cloud storage endpoint.

This way is better for larger data files. And also you have more control over the look.

It's not super hard, but also not trivial.

ml2s commented 1 month ago

Thank you so much for the reply! I'll try the easy option first, my output file is small.

loretoparisi commented 1 month ago

👍🏾

raphsaeed commented 1 month ago

Thanks, download file would be nice feature, for now I am just using download link option. Image