Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -181,7 +181,7 @@ async def process_url(url, depth):
|
|
181 |
if not all_pages:
|
182 |
return "No pages were successfully crawled. Please check the URL and try again."
|
183 |
pdf_buffer = website_to_pdf(all_pages)
|
184 |
-
return pdf_buffer
|
185 |
except Exception as e:
|
186 |
logger.error(f"Error in process_url: {str(e)}")
|
187 |
return f"An error occurred: {str(e)}"
|
@@ -230,13 +230,13 @@ def update_output(n_clicks, url, depth):
|
|
230 |
if not url:
|
231 |
return "Please enter a valid URL."
|
232 |
|
233 |
-
|
234 |
|
235 |
-
if isinstance(
|
236 |
-
return
|
237 |
|
238 |
try:
|
239 |
-
encoded = base64.b64encode(
|
240 |
|
241 |
return html.Div([
|
242 |
html.H4("PDF Generated Successfully"),
|
|
|
181 |
if not all_pages:
|
182 |
return "No pages were successfully crawled. Please check the URL and try again."
|
183 |
pdf_buffer = website_to_pdf(all_pages)
|
184 |
+
return pdf_buffer.getvalue() # Return bytes instead of BytesIO object
|
185 |
except Exception as e:
|
186 |
logger.error(f"Error in process_url: {str(e)}")
|
187 |
return f"An error occurred: {str(e)}"
|
|
|
230 |
if not url:
|
231 |
return "Please enter a valid URL."
|
232 |
|
233 |
+
pdf_content = asyncio.run(process_url(url, depth))
|
234 |
|
235 |
+
if isinstance(pdf_content, str):
|
236 |
+
return pdf_content # This is an error message
|
237 |
|
238 |
try:
|
239 |
+
encoded = base64.b64encode(pdf_content).decode()
|
240 |
|
241 |
return html.Div([
|
242 |
html.H4("PDF Generated Successfully"),
|