Update app.py
Browse files
app.py
CHANGED
|
@@ -846,58 +846,47 @@ with tab5:
|
|
| 846 |
|
| 847 |
# Additional download options
|
| 848 |
st.markdown("---")
|
| 849 |
-
st.markdown("### π¦ Bulk Download
|
| 850 |
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
("executive_summary.txt", "text/plain"),
|
| 868 |
-
("uncertain_entities.csv", "text/csv")
|
| 869 |
-
]
|
| 870 |
-
|
| 871 |
-
for filename, mime_type in files_to_add:
|
| 872 |
-
try:
|
| 873 |
-
file_url = f"https://huggingface.co/spaces/Malaji71/list/resolve/main/{filename}"
|
| 874 |
-
response = requests.get(file_url)
|
| 875 |
-
if response.status_code == 200:
|
| 876 |
-
zip_file.writestr(filename, response.content)
|
| 877 |
-
except:
|
| 878 |
-
# Add placeholder if file not available
|
| 879 |
-
zip_file.writestr(f"{filename}.missing", f"File {filename} not available")
|
| 880 |
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
|
|
|
|
|
|
| 898 |
|
| 899 |
st.markdown("---")
|
| 900 |
-
st.markdown("**π
|
| 901 |
st.markdown("""
|
| 902 |
- `complete_analysis.json` - Complete analysis data in JSON format
|
| 903 |
- `analysis_report.txt` - Detailed human-readable report
|
|
|
|
| 846 |
|
| 847 |
# Additional download options
|
| 848 |
st.markdown("---")
|
| 849 |
+
st.markdown("### π¦ Bulk Download")
|
| 850 |
|
| 851 |
+
if st.button("π₯ Download All Analysis Files", use_container_width=True):
|
| 852 |
+
try:
|
| 853 |
+
# Create a ZIP file with all analysis files
|
| 854 |
+
import zipfile
|
| 855 |
+
from io import BytesIO
|
| 856 |
+
|
| 857 |
+
zip_buffer = BytesIO()
|
| 858 |
+
|
| 859 |
+
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
|
| 860 |
+
# Try to add each file
|
| 861 |
+
files_to_add = [
|
| 862 |
+
("complete_analysis.json", "application/json"),
|
| 863 |
+
("analysis_report.txt", "text/plain"),
|
| 864 |
+
("executive_summary.txt", "text/plain"),
|
| 865 |
+
("uncertain_entities.csv", "text/csv")
|
| 866 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 867 |
|
| 868 |
+
for filename, mime_type in files_to_add:
|
| 869 |
+
try:
|
| 870 |
+
file_url = f"https://huggingface.co/spaces/Malaji71/list/resolve/main/{filename}"
|
| 871 |
+
response = requests.get(file_url)
|
| 872 |
+
if response.status_code == 200:
|
| 873 |
+
zip_file.writestr(filename, response.content)
|
| 874 |
+
except:
|
| 875 |
+
# Add placeholder if file not available
|
| 876 |
+
zip_file.writestr(f"{filename}.missing", f"File {filename} not available")
|
| 877 |
+
|
| 878 |
+
st.download_button(
|
| 879 |
+
label="π¦ Download ZIP Package",
|
| 880 |
+
data=zip_buffer.getvalue(),
|
| 881 |
+
file_name=f"terror_finance_analysis_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip",
|
| 882 |
+
mime="application/zip",
|
| 883 |
+
help="Download all analysis files in a single ZIP package"
|
| 884 |
+
)
|
| 885 |
+
except Exception as e:
|
| 886 |
+
st.error(f"Error creating ZIP file: {str(e)}")
|
| 887 |
|
| 888 |
st.markdown("---")
|
| 889 |
+
st.markdown("**π Analysis Package Contents:**")
|
| 890 |
st.markdown("""
|
| 891 |
- `complete_analysis.json` - Complete analysis data in JSON format
|
| 892 |
- `analysis_report.txt` - Detailed human-readable report
|