nesticot commited on
Commit
e2766f6
·
verified ·
1 Parent(s): a77c881

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
app.py CHANGED
@@ -276,16 +276,31 @@ def server(input, output, session):
276
  fig.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01)
277
 
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  # Download handler for CSV
280
  @session.download(filename="data.csv")
281
  def download_data():
282
- # Create a string buffer
283
- buffer = StringIO()
284
- # Write the DataFrame to the buffer
285
- cached_data().write_csv(buffer)
286
- buffer.seek(0)
287
- # Get the string value and return it
288
- return buffer.getvalue()
289
 
290
 
291
 
 
276
  fig.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01)
277
 
278
 
279
+ # # Download handler for CSV
280
+ # @session.download(filename="data.csv")
281
+ # def download_data():
282
+ # # Create a string buffer
283
+ # buffer = StringIO()
284
+ # # Write the DataFrame to the buffer
285
+ # cached_data().write_csv(buffer)
286
+ # buffer.seek(0)
287
+ # # Get the string value and return it
288
+ # return buffer.getvalue()
289
+
290
+ # Reactive expression for the dataset
291
+ @reactive.calc
292
+ def dataset():
293
+ np.random.seed(123)
294
+ return pd.DataFrame({
295
+ 'x': np.random.normal(0, 1, input.num_points()),
296
+ 'y': np.random.normal(0, 1, input.num_points())
297
+ })
298
+
299
  # Download handler for CSV
300
  @session.download(filename="data.csv")
301
  def download_data():
302
+ # Get the current dataset and save it to CSV
303
+ return dataset().to_csv(index=False)
 
 
 
 
 
304
 
305
 
306