kshitij10000 commited on
Commit
d74a592
·
1 Parent(s): 728b983

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -1
app.py CHANGED
@@ -143,7 +143,19 @@ else:
143
  prs.save(presentation_filename)
144
 
145
  # Provide a direct download link to the saved file
146
- st.markdown(f"### Download your presentation: [Download {presentation_title}](./{presentation_filename})")
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
  except json.JSONDecodeError as e:
149
  st.error("Error parsing JSON response from OpenAI.")
 
143
  prs.save(presentation_filename)
144
 
145
  # Provide a direct download link to the saved file
146
+ if os.path.exists(presentation_filename):
147
+ with open(presentation_filename, "rb") as file:
148
+ file_bytes = file.read()
149
+ st.download_button(
150
+ label=f"📥 Download {presentation_title}",
151
+ data=file_bytes,
152
+ file_name=presentation_filename,
153
+ key=f"download_{presentation_filename}",
154
+ )
155
+
156
+ os.remove(presentation_filename)
157
+ else:
158
+ st.error("Error: Presentation file not found.")
159
 
160
  except json.JSONDecodeError as e:
161
  st.error("Error parsing JSON response from OpenAI.")