Update app.py
Browse files
app.py
CHANGED
|
@@ -27,11 +27,11 @@ def log_conversion(status, input_pdf, output_svg, output_pdf):
|
|
| 27 |
|
| 28 |
# Gradio interface function
|
| 29 |
def process_pdf(file, width, height):
|
| 30 |
-
input_pdf = os.path.join(INPUT_FOLDER, "uploaded_file.pdf")
|
| 31 |
try:
|
| 32 |
-
# Save the uploaded file
|
|
|
|
| 33 |
with open(input_pdf, "wb") as f:
|
| 34 |
-
f.write(file)
|
| 35 |
|
| 36 |
# Step 1: Convert PDF to SVG
|
| 37 |
convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height)
|
|
@@ -44,7 +44,8 @@ def process_pdf(file, width, height):
|
|
| 44 |
|
| 45 |
return SVG_OUTPUT, PDF_OUTPUT
|
| 46 |
except Exception as e:
|
| 47 |
-
|
|
|
|
| 48 |
return f"Error processing file: {e}", None
|
| 49 |
|
| 50 |
# Gradio interface
|
|
|
|
| 27 |
|
| 28 |
# Gradio interface function
|
| 29 |
def process_pdf(file, width, height):
|
|
|
|
| 30 |
try:
|
| 31 |
+
# Save the uploaded file to disk
|
| 32 |
+
input_pdf = os.path.join(INPUT_FOLDER, file.name)
|
| 33 |
with open(input_pdf, "wb") as f:
|
| 34 |
+
f.write(file.read())
|
| 35 |
|
| 36 |
# Step 1: Convert PDF to SVG
|
| 37 |
convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height)
|
|
|
|
| 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 f"Error processing file: {e}", None
|
| 50 |
|
| 51 |
# Gradio interface
|