Ramesh-vani commited on
Commit
b9f6afe
·
verified ·
1 Parent(s): 35fa4da

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -51,29 +51,29 @@ def inline_resources(soup, base_url):
51
 
52
  return soup
53
 
54
- # async def send_html_chunked(websocket, html):
55
- # chunk_size = 1024 # Define your chunk size here
56
- # for i in range(0, len(html), chunk_size):
57
- # chunk = html[i:i + chunk_size]
58
- # await websocket.send(chunk)
59
- # await asyncio.sleep(0.1) # Add a small delay if needed
60
-
61
- async def send_html_chunks(ws, html_data, chunk_size=1024):
62
 
63
 
64
- # Split the HTML data into chunks
65
- total_chunks = math.ceil(len(html_data) / chunk_size)
66
- for i in range(total_chunks):
67
- start = i * chunk_size
68
- end = min(start + chunk_size, len(html_data))
69
- chunk = html_data[start:end]
70
 
71
- # Send the chunk with chunk number and total chunks information
72
- chunk_message = f"chunk_{i+1}/{total_chunks}:{chunk}"
73
- await ws.send(chunk_message.encode())
74
 
75
- # Wait for a short interval before sending the next chunk
76
- await asyncio.sleep(0.1) # Adjust as needed
77
 
78
  def auto_detect_mode(content):
79
  if isinstance(content, str):
 
51
 
52
  return soup
53
 
54
+ async def send_html_chunks(websocket, html):
55
+ chunk_size = 1024 # Define your chunk size here
56
+ for i in range(0, len(html), chunk_size):
57
+ chunk = html[i:i + chunk_size]
58
+ await websocket.send(chunk)
59
+ await asyncio.sleep(0.1) # Add a small delay if needed
60
+
61
+ # async def send_html_chunks(ws, html_data, chunk_size=1024):
62
 
63
 
64
+ # # Split the HTML data into chunks
65
+ # total_chunks = math.ceil(len(html_data) / chunk_size)
66
+ # for i in range(total_chunks):
67
+ # start = i * chunk_size
68
+ # end = min(start + chunk_size, len(html_data))
69
+ # chunk = html_data[start:end]
70
 
71
+ # # Send the chunk with chunk number and total chunks information
72
+ # chunk_message = f"chunk_{i+1}/{total_chunks}:{chunk}"
73
+ # await ws.send(chunk_message.encode())
74
 
75
+ # # Wait for a short interval before sending the next chunk
76
+ # await asyncio.sleep(0.1) # Adjust as needed
77
 
78
  def auto_detect_mode(content):
79
  if isinstance(content, str):