Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -495,6 +495,24 @@ async def handle_user_input(websocket,key, process, connected,process_ids):
|
|
495 |
response = {"error": "Unsupported method"}
|
496 |
# Parse HTML content
|
497 |
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
# Find and modify CSS links
|
499 |
for link in soup.find_all("link", rel="stylesheet", href=True):
|
500 |
if link['href'].startswith('/'):
|
@@ -864,6 +882,24 @@ async def exe(websocket,connected,key,process_ids):
|
|
864 |
response = {"error": "Unsupported method"}
|
865 |
# Parse HTML content
|
866 |
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
867 |
# Find and modify CSS links
|
868 |
for link in soup.find_all("link", rel="stylesheet", href=True):
|
869 |
if link['href'].startswith('/'):
|
|
|
495 |
response = {"error": "Unsupported method"}
|
496 |
# Parse HTML content
|
497 |
soup = BeautifulSoup(response.text, "html.parser")
|
498 |
+
# Function to join relative URLs with base URL
|
499 |
+
def join_url_with_base(url):
|
500 |
+
if url.startswith('/'):
|
501 |
+
return urljoin(url, base_host)
|
502 |
+
else:
|
503 |
+
return urljoin(url, base_url.geturl())
|
504 |
+
|
505 |
+
# Find and modify CSS links
|
506 |
+
for link in soup.find_all("link", rel="stylesheet", href=True):
|
507 |
+
link['href'] = join_url_with_base(link['href'])
|
508 |
+
|
509 |
+
# Find and modify JS links
|
510 |
+
for script in soup.find_all("script", src=True):
|
511 |
+
script['src'] = join_url_with_base(script['src'])
|
512 |
+
|
513 |
+
# Find and modify regular anchor links
|
514 |
+
for anchor in soup.find_all("a", href=True):
|
515 |
+
anchor['href'] = join_url_with_base(anchor['href'])
|
516 |
# Find and modify CSS links
|
517 |
for link in soup.find_all("link", rel="stylesheet", href=True):
|
518 |
if link['href'].startswith('/'):
|
|
|
882 |
response = {"error": "Unsupported method"}
|
883 |
# Parse HTML content
|
884 |
soup = BeautifulSoup(response.text, "html.parser")
|
885 |
+
# Function to join relative URLs with base URL
|
886 |
+
def join_url_with_base(url):
|
887 |
+
if url.startswith('/'):
|
888 |
+
return urljoin(url, base_host)
|
889 |
+
else:
|
890 |
+
return urljoin(url, base_url.geturl())
|
891 |
+
|
892 |
+
# Find and modify CSS links
|
893 |
+
for link in soup.find_all("link", rel="stylesheet", href=True):
|
894 |
+
link['href'] = join_url_with_base(link['href'])
|
895 |
+
|
896 |
+
# Find and modify JS links
|
897 |
+
for script in soup.find_all("script", src=True):
|
898 |
+
script['src'] = join_url_with_base(script['src'])
|
899 |
+
|
900 |
+
# Find and modify regular anchor links
|
901 |
+
for anchor in soup.find_all("a", href=True):
|
902 |
+
anchor['href'] = join_url_with_base(anchor['href'])
|
903 |
# Find and modify CSS links
|
904 |
for link in soup.find_all("link", rel="stylesheet", href=True):
|
905 |
if link['href'].startswith('/'):
|