awacke1 commited on
Commit
c111cec
·
1 Parent(s): 57ebb7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -30,9 +30,12 @@ def create_file(filename, prompt, response):
30
  file.write(f"<h1>Prompt:</h1> <p>{prompt}</p> <h1>Response:</h1> <p>{response}</p>")
31
 
32
  def get_table_download_link(file_path):
33
- href = f'<a href="{file_path}" target="_blank">{os.path.basename(file_path)}</a>'
 
 
 
34
  return href
35
-
36
  def main():
37
  st.title("Chat with AI")
38
 
 
30
  file.write(f"<h1>Prompt:</h1> <p>{prompt}</p> <h1>Response:</h1> <p>{response}</p>")
31
 
32
  def get_table_download_link(file_path):
33
+ with open(file_path, 'r') as file:
34
+ data = file.read()
35
+ b64 = base64.b64encode(data.encode()).decode()
36
+ href = f'<a href="data:file/txt;base64,{b64}" download="{os.path.basename(file_path)}">{os.path.basename(file_path)}</a>'
37
  return href
38
+
39
  def main():
40
  st.title("Chat with AI")
41