SumayyaAli commited on
Commit
db38720
1 Parent(s): dad2778

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -73,9 +73,12 @@ def main():
73
  if uploaded_file is not None:
74
  if st.button("Summarize"):
75
  col1, col2 = st.columns(2)
76
- filepath = "data/"+uploaded_file.name
77
- with open(filepath, "wb") as temp_file:
78
  temp_file.write(uploaded_file.read())
 
 
 
79
  with col1:
80
  st.info("Uploaded File")
81
  pdf_view = displayPDF(filepath)
@@ -84,6 +87,9 @@ def main():
84
  summary = llm_pipeline(filepath)
85
  st.info("Summarization Complete")
86
  st.success(summary)
 
 
 
87
 
88
 
89
 
 
73
  if uploaded_file is not None:
74
  if st.button("Summarize"):
75
  col1, col2 = st.columns(2)
76
+ # Use a temporary filename directly
77
+ with tempfile.NamedTemporaryFile(delete=False) as temp_file:
78
  temp_file.write(uploaded_file.read())
79
+ temp_file.flush() # Ensure contents are written to disk
80
+ filepath = temp_file.name
81
+
82
  with col1:
83
  st.info("Uploaded File")
84
  pdf_view = displayPDF(filepath)
 
87
  summary = llm_pipeline(filepath)
88
  st.info("Summarization Complete")
89
  st.success(summary)
90
+ # Clean up the temporary file
91
+ os.remove(filepath)
92
+
93
 
94
 
95