ceckenrode commited on
Commit
c2665e5
1 Parent(s): 605bb46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -143,13 +143,12 @@ def append_file(file_path, content):
143
  except:
144
  return "Error occurred while appending to file."
145
 
146
- def download_csv(file_path, content):
147
- try:
148
- with open(file_path, "wb") as file:
149
- writer = csv.writer(file)
150
- return f"Successfully downloaded {file_path}."
151
- except:
152
- return "Error occurred while downloading file."
153
 
154
  title = """<h1 align="center">Memory Chat Story Generator ChatGPT</h1>"""
155
  description = """
 
143
  except:
144
  return "Error occurred while appending to file."
145
 
146
+ def download_csv(file_path):
147
+ with open(file_path, "rb") as f:
148
+ contents = f.read()
149
+ b64 = base64.b64encode(contents).decode()
150
+ href = f'<a href="data:application/octet-stream;base64,{b64}" download="{file_path}">Download</a>'
151
+ return href
 
152
 
153
  title = """<h1 align="center">Memory Chat Story Generator ChatGPT</h1>"""
154
  description = """