Update src/streamlit_app.py

#12
Files changed (1) hide show
  1. src/streamlit_app.py +30 -13
src/streamlit_app.py CHANGED
@@ -61,14 +61,31 @@ input_method = st.sidebar.selectbox("Choose a method" , ["Choose input method...
61
  st.sidebar.title("Upload your pdf")
62
 
63
  main_placeholder = st.empty()
64
- #Document upload
65
- uploaded_file = st.sidebar.file_uploader("_____________________________________", type="pdf", accept_multiple_files=True)
66
- st.sidebar.write("Press Submit to process:")
67
 
68
 
69
 
 
 
 
 
 
70
  process = st.sidebar.button("Submit")
 
71
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
 
74
 
@@ -82,17 +99,17 @@ process = st.sidebar.button("Submit")
82
  # st.warning("Please upload a PDF file.")
83
 
84
  # Document processing
85
- if process:
86
- if uploaded_file:
87
- # Save to /tmp/ before processing
88
- file_path = f"/tmp/{uploaded_file.name}"
89
- with open(file_path, "wb") as f:
90
- f.write(uploaded_file.getbuffer())
91
 
92
- # Call your existing logic with the saved path
93
- process_pdf(file_path)
94
- else:
95
- st.warning("Please upload a PDF file.")
96
 
97
 
98
 
 
61
  st.sidebar.title("Upload your pdf")
62
 
63
  main_placeholder = st.empty()
64
+ # #Document upload
65
+ # uploaded_file = st.sidebar.file_uploader("_____________________________________", type="pdf", accept_multiple_files=True)
66
+ # st.sidebar.write("Press Submit to process:")
67
 
68
 
69
 
70
+ # process = st.sidebar.button("Submit")
71
+
72
+ uploaded_files = st.sidebar.file_uploader("Upload your PDFs", type="pdf", accept_multiple_files=True)
73
+
74
+
75
  process = st.sidebar.button("Submit")
76
+ # Document processing
77
 
78
+ if process:
79
+ if uploaded_files:
80
+ for uploaded_file in uploaded_files:
81
+ file_path = f"/tmp/{uploaded_file.name}"
82
+ with open(file_path, "wb") as f:
83
+ f.write(uploaded_file.getbuffer())
84
+
85
+ st.success(f"{uploaded_file.name} uploaded successfully!")
86
+ process_pdf(file_path)
87
+ else:
88
+ st.warning("Please upload at least one PDF file.")
89
 
90
 
91
 
 
99
  # st.warning("Please upload a PDF file.")
100
 
101
  # Document processing
102
+ # if process:
103
+ # if uploaded_file:
104
+ # # Save to /tmp/ before processing
105
+ # file_path = f"/tmp/{uploaded_file.name}"
106
+ # with open(file_path, "wb") as f:
107
+ # f.write(uploaded_file.getbuffer())
108
 
109
+ # # Call your existing logic with the saved path
110
+ # process_pdf(file_path)
111
+ # else:
112
+ # st.warning("Please upload a PDF file.")
113
 
114
 
115