Malaji71 commited on
Commit
c5dceed
Β·
verified Β·
1 Parent(s): 3a591f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -48
app.py CHANGED
@@ -846,58 +846,47 @@ with tab5:
846
 
847
  # Additional download options
848
  st.markdown("---")
849
- st.markdown("### πŸ“¦ Bulk Download Options")
850
 
851
- col1, col2 = st.columns(2)
852
-
853
- with col1:
854
- if st.button("πŸ“₯ Download All Analysis Files", use_container_width=True):
855
- try:
856
- # Create a ZIP file with all analysis files
857
- import zipfile
858
- from io import BytesIO
859
-
860
- zip_buffer = BytesIO()
861
-
862
- with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
863
- # Try to add each file
864
- files_to_add = [
865
- ("complete_analysis.json", "application/json"),
866
- ("analysis_report.txt", "text/plain"),
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
- st.download_button(
882
- label="πŸ“¦ Download ZIP",
883
- data=zip_buffer.getvalue(),
884
- file_name=f"terror_finance_analysis_{datetime.now().strftime('%Y%m%d_%H%M%S')}.zip",
885
- mime="application/zip"
886
- )
887
- except Exception as e:
888
- st.error(f"Error creating ZIP file: {str(e)}")
889
-
890
- with col2:
891
- st.markdown("**πŸ’‘ File Upload Instructions:**")
892
- st.markdown("""
893
- To enable all downloads:
894
- 1. Upload processed files to your Hugging Face Space
895
- 2. Files should be in the root directory
896
- 3. Ensure files are publicly accessible
897
- """)
 
 
898
 
899
  st.markdown("---")
900
- st.markdown("**πŸ“ Available Analysis Files:**")
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