amendolajine commited on
Commit
7e5f9d1
·
1 Parent(s): 1842832

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -28,16 +28,17 @@ def extract_abstract(pdf_bytes):
28
  return "Error in abstract extraction"
29
 
30
  def process_text(uploaded_file):
31
- # Debugging: Print the type and contents of the uploaded_file
32
  print(f"Uploaded file type: {type(uploaded_file)}")
33
- print(f"Uploaded file content: {uploaded_file}")
34
 
35
- # Check if uploaded_file is a dictionary with 'data' key
36
- if isinstance(uploaded_file, dict) and 'data' in uploaded_file:
37
- pdf_bytes = uploaded_file['data']
38
- else:
39
- print("Uploaded file is not in the expected format")
40
- return "File content could not be retrieved", None
 
41
 
42
  try:
43
  abstract_text = extract_abstract(pdf_bytes)
 
28
  return "Error in abstract extraction"
29
 
30
  def process_text(uploaded_file):
31
+ # Debugging: Print the type and path of the uploaded_file
32
  print(f"Uploaded file type: {type(uploaded_file)}")
33
+ print(f"Uploaded file path: {uploaded_file}")
34
 
35
+ # Read PDF file from the path
36
+ try:
37
+ with open(uploaded_file, "rb") as file:
38
+ pdf_bytes = file.read()
39
+ except Exception as e:
40
+ print(f"Error reading file from path: {e}")
41
+ return "Error reading PDF file", None
42
 
43
  try:
44
  abstract_text = extract_abstract(pdf_bytes)