Additionally, I wanted to say that I am aware the cherrypy and flask have helper methods for sending files. They will of course not work inside of a bokeh server. I dont quite see how to send a HTTPResponse object. I would also prefer not to rewrite my entire app in Flask or CherryPy in order to embed these dashboards just for the sake of using the send_file function.
···
On Monday, April 18, 2016 at 2:33:25 PM UTC-4, Jordan Bramble wrote:
Hi I have a bokeh server app. running in 0.11.1. One component of my app is a DataTable. I want to save the data in this table as a .csv, so that someone can click a button and download the .csv through their browser. Here is a snipped of what I have done so far.
def download():
export = pd.DataFrame(source6.data)
buffer = io.StringIO()
export.to_csv(buffer, index=False, encoding=‘utf-8’)
#save(vform(data_table))
controls = [store_name, inventory, min_year, max_year, min_month, max_month, button]
for control in controls[:-1]:
control.on_change(‘value’, update)
controls[-1].on_click(download)
the download function, converts the data souce tied to the dataTable to a dataframe. then writes it to the buffer. from their I have no idea how to download it in the browser.
I have a button defined in the app. When this button is clicked the download function is called. but of course that function is not complete. So I am hoping someone can help me download it.
I tried to use the bokeh method save(), but when running on the server, the save function is ignored.
Additionally, I have another issue where everytime I click a button the page is reloaded and a new session is created. This is a bug I believe, that has supposedly been fixed in a PR.
Thanks for the help. Attached are pictures of my app.