Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -170,18 +170,15 @@ def website_to_pdf(all_pages):
|
|
170 |
if pdf.get_y() > 250: # Add a new page if the current page is almost full
|
171 |
pdf.add_page()
|
172 |
|
173 |
-
|
174 |
-
pdf.output(pdf_buffer)
|
175 |
-
pdf_buffer.seek(0)
|
176 |
-
return pdf_buffer
|
177 |
|
178 |
async def process_url(url, depth):
|
179 |
try:
|
180 |
all_pages = await crawl_pages(url, depth)
|
181 |
if not all_pages:
|
182 |
return "No pages were successfully crawled. Please check the URL and try again."
|
183 |
-
|
184 |
-
return
|
185 |
except Exception as e:
|
186 |
logger.error(f"Error in process_url: {str(e)}")
|
187 |
return f"An error occurred: {str(e)}"
|
|
|
170 |
if pdf.get_y() > 250: # Add a new page if the current page is almost full
|
171 |
pdf.add_page()
|
172 |
|
173 |
+
return pdf.output(dest='S').encode('latin-1') # Return bytes instead of BytesIO object
|
|
|
|
|
|
|
174 |
|
175 |
async def process_url(url, depth):
|
176 |
try:
|
177 |
all_pages = await crawl_pages(url, depth)
|
178 |
if not all_pages:
|
179 |
return "No pages were successfully crawled. Please check the URL and try again."
|
180 |
+
pdf_content = website_to_pdf(all_pages)
|
181 |
+
return pdf_content # This is now bytes, not BytesIO
|
182 |
except Exception as e:
|
183 |
logger.error(f"Error in process_url: {str(e)}")
|
184 |
return f"An error occurred: {str(e)}"
|