Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def get_page_content(url):
|
|
34 |
return content
|
35 |
except Exception as e:
|
36 |
logger.error(f"Error processing {url}: {str(e)}")
|
37 |
-
return [
|
38 |
|
39 |
def get_links(url, base_url):
|
40 |
try:
|
@@ -80,8 +80,7 @@ def crawl_pages(base_url, max_depth):
|
|
80 |
|
81 |
for future in as_completed(futures):
|
82 |
url, content, depth = future.result()
|
83 |
-
|
84 |
-
all_pages.append((url, content))
|
85 |
|
86 |
return all_pages
|
87 |
|
@@ -118,15 +117,12 @@ def process_url(url, depth):
|
|
118 |
return pdf_file
|
119 |
except Exception as e:
|
120 |
logger.error(f"Error in process_url: {str(e)}")
|
121 |
-
return
|
122 |
|
123 |
def threaded_process_url(url, depth):
|
124 |
with ThreadPoolExecutor() as executor:
|
125 |
future = executor.submit(process_url, url, depth)
|
126 |
-
|
127 |
-
if result is None:
|
128 |
-
return gr.update(value=None, visible=False)
|
129 |
-
return gr.update(value=result, visible=True)
|
130 |
|
131 |
iface = gr.Interface(
|
132 |
fn=threaded_process_url,
|
|
|
34 |
return content
|
35 |
except Exception as e:
|
36 |
logger.error(f"Error processing {url}: {str(e)}")
|
37 |
+
return [f"Error processing {url}: {str(e)}"]
|
38 |
|
39 |
def get_links(url, base_url):
|
40 |
try:
|
|
|
80 |
|
81 |
for future in as_completed(futures):
|
82 |
url, content, depth = future.result()
|
83 |
+
all_pages.append((url, content))
|
|
|
84 |
|
85 |
return all_pages
|
86 |
|
|
|
117 |
return pdf_file
|
118 |
except Exception as e:
|
119 |
logger.error(f"Error in process_url: {str(e)}")
|
120 |
+
return f"An error occurred: {str(e)}"
|
121 |
|
122 |
def threaded_process_url(url, depth):
|
123 |
with ThreadPoolExecutor() as executor:
|
124 |
future = executor.submit(process_url, url, depth)
|
125 |
+
return future.result()
|
|
|
|
|
|
|
126 |
|
127 |
iface = gr.Interface(
|
128 |
fn=threaded_process_url,
|