dammy commited on
Commit
911a8be
·
1 Parent(s): 6c36800

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -7
app.py CHANGED
@@ -73,15 +73,35 @@ def load_document(pdf_filename):
73
 
74
  return 'Success'
75
 
76
-
 
 
77
  def upload_pdf(file):
78
- # Save the uploaded file
79
- file_name = file.name
80
- pdf_filename = os.path.basename(file_path)
 
 
 
 
 
 
 
81
 
82
- # messsage = load_document(pdf_filename)
83
- messsage = 'success'
84
- return messsage
 
 
 
 
 
 
 
 
 
 
 
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