Update app.py
Browse files
app.py
CHANGED
@@ -73,15 +73,35 @@ def load_document(pdf_filename):
|
|
73 |
|
74 |
return 'Success'
|
75 |
|
76 |
-
|
|
|
|
|
77 |
def upload_pdf(file):
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
|
87 |
|
|
|
73 |
|
74 |
return 'Success'
|
75 |
|
76 |
+
import gradio as gr
|
77 |
+
import os
|
78 |
+
|
79 |
def upload_pdf(file):
|
80 |
+
try:
|
81 |
+
# Check if the file is not None before accessing its attributes
|
82 |
+
if file is not None:
|
83 |
+
# Save the uploaded file
|
84 |
+
file_name = file.name
|
85 |
+
# file.save(file_name)
|
86 |
+
|
87 |
+
return file_name
|
88 |
+
else:
|
89 |
+
return "No file uploaded."
|
90 |
|
91 |
+
except Exception as e:
|
92 |
+
return f"An error occurred: {e}"
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
|
97 |
+
# def upload_pdf(file):
|
98 |
+
# # Save the uploaded file
|
99 |
+
# file_name = file.name
|
100 |
+
# pdf_filename = os.path.basename(file_path)
|
101 |
+
|
102 |
+
# # messsage = load_document(pdf_filename)
|
103 |
+
# messsage = 'success'
|
104 |
+
# return messsage
|
105 |
|
106 |
|
107 |
|