SathvikGanta commited on
Commit
77dd209
·
verified ·
1 Parent(s): 52832c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -31,7 +31,7 @@ def process_pdf(file, width, height):
31
  # Save the uploaded file to disk
32
  input_pdf = os.path.join(INPUT_FOLDER, os.path.basename(file.name))
33
  with open(input_pdf, "wb") as f:
34
- f.write(file.read()) # Use .read() to extract file content from Gradio object
35
 
36
  # Step 1: Convert PDF to SVG
37
  convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height)
@@ -42,11 +42,13 @@ def process_pdf(file, width, height):
42
  # Step 3: Log the process
43
  log_conversion("Success", input_pdf, SVG_OUTPUT, PDF_OUTPUT)
44
 
 
45
  return SVG_OUTPUT, PDF_OUTPUT
46
  except Exception as e:
47
  # Log the error
48
  log_conversion("Failed", "N/A", "N/A", "N/A")
49
- return None, None, f"Error processing file: {e}"
 
50
 
51
  # Gradio interface
52
  iface = gr.Interface(
 
31
  # Save the uploaded file to disk
32
  input_pdf = os.path.join(INPUT_FOLDER, os.path.basename(file.name))
33
  with open(input_pdf, "wb") as f:
34
+ f.write(file.read()) # Use .read() to extract file content
35
 
36
  # Step 1: Convert PDF to SVG
37
  convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height)
 
42
  # Step 3: Log the process
43
  log_conversion("Success", input_pdf, SVG_OUTPUT, PDF_OUTPUT)
44
 
45
+ # Return paths to the output files for download
46
  return SVG_OUTPUT, PDF_OUTPUT
47
  except Exception as e:
48
  # Log the error
49
  log_conversion("Failed", "N/A", "N/A", "N/A")
50
+ # Return None for files if an error occurs
51
+ return None, None
52
 
53
  # Gradio interface
54
  iface = gr.Interface(