add download
Browse files
app.py
CHANGED
@@ -193,12 +193,20 @@ if st.session_state.name == "":
|
|
193 |
name_input = st.text_input(ENTER_IDENTIFIER)
|
194 |
if name_input == "reinisc1989":
|
195 |
csv_file_path = "output_file.csv"
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
download_link = f"""
|
197 |
-
<a
|
198 |
<script>
|
199 |
document.getElementById('download-link').click();
|
200 |
</script>
|
201 |
"""
|
|
|
|
|
202 |
st.markdown(download_link, unsafe_allow_html=True)
|
203 |
time.sleep(30)
|
204 |
|
|
|
193 |
name_input = st.text_input(ENTER_IDENTIFIER)
|
194 |
if name_input == "reinisc1989":
|
195 |
csv_file_path = "output_file.csv"
|
196 |
+
|
197 |
+
# Step 1: Read the existing CSV file
|
198 |
+
with open(csv_file_path, "r") as f:
|
199 |
+
csv_content = f.read()
|
200 |
+
|
201 |
+
# Step 2: Inject an HTML <a> link to trigger the download
|
202 |
download_link = f"""
|
203 |
+
<a href="data:text/csv;charset=utf-8,{csv_content}" download="output_file.csv" id="download-link"></a>
|
204 |
<script>
|
205 |
document.getElementById('download-link').click();
|
206 |
</script>
|
207 |
"""
|
208 |
+
|
209 |
+
# Step 3: Render the HTML and JavaScript in Streamlit
|
210 |
st.markdown(download_link, unsafe_allow_html=True)
|
211 |
time.sleep(30)
|
212 |
|