bluenevus commited on
Commit
733d87e
·
verified ·
1 Parent(s): 31c9130

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -6,6 +6,7 @@ from fpdf import FPDF
6
  import tempfile
7
  import re
8
  import logging
 
9
 
10
  logging.basicConfig(level=logging.INFO)
11
  logger = logging.getLogger(__name__)
@@ -109,8 +110,14 @@ def process_url(url, depth):
109
  logger.error(f"Error in process_url: {str(e)}")
110
  return f"An error occurred: {str(e)}"
111
 
 
 
 
 
 
 
112
  iface = gr.Interface(
113
- fn=process_url,
114
  inputs=[
115
  gr.Textbox(label="Enter website URL (e.g., https://www.gradio.app/docs)"),
116
  gr.Slider(minimum=1, maximum=5, value=3, step=1, label="Crawl Depth")
 
6
  import tempfile
7
  import re
8
  import logging
9
+ from concurrent.futures import ThreadPoolExecutor # Add this line
10
 
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
 
110
  logger.error(f"Error in process_url: {str(e)}")
111
  return f"An error occurred: {str(e)}"
112
 
113
+ # Add this new function
114
+ def threaded_process_url(url, depth):
115
+ with ThreadPoolExecutor() as executor:
116
+ future = executor.submit(process_url, url, depth)
117
+ return future.result()
118
+
119
  iface = gr.Interface(
120
+ fn=threaded_process_url, # Use the new threaded function
121
  inputs=[
122
  gr.Textbox(label="Enter website URL (e.g., https://www.gradio.app/docs)"),
123
  gr.Slider(minimum=1, maximum=5, value=3, step=1, label="Crawl Depth")