Update app.py
Browse files
app.py
CHANGED
|
@@ -29,9 +29,9 @@ def log_conversion(status, input_pdf, output_svg, output_pdf):
|
|
| 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)
|
| 35 |
|
| 36 |
# Step 1: Convert PDF to SVG
|
| 37 |
convert_pdf_to_svg(input_pdf, SVG_OUTPUT, width, height)
|
|
@@ -46,7 +46,7 @@ def process_pdf(file, width, height):
|
|
| 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}"
|
| 50 |
|
| 51 |
# Gradio interface
|
| 52 |
iface = gr.Interface(
|
|
|
|
| 29 |
def process_pdf(file, width, height):
|
| 30 |
try:
|
| 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)
|
|
|
|
| 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(
|