Felguk commited on
Commit
7a18d26
·
verified ·
1 Parent(s): 2d21ec5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -1
app.py CHANGED
@@ -4,6 +4,20 @@ from urllib.parse import urlparse, urljoin
4
  from bs4 import BeautifulSoup
5
  import asyncio
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  # Common functions
8
  def is_valid_url(url):
9
  """Checks if the string is a valid URL."""
@@ -214,7 +228,7 @@ iface.launch()
214
  return code.strip()
215
 
216
  # Create the Gradio interface
217
- with gr.Blocks() as demo: # Убрали параметр css
218
  gr.HTML(copy_button_html) # Add the "Copy Code" script
219
 
220
  with gr.Tabs():
 
4
  from bs4 import BeautifulSoup
5
  import asyncio
6
 
7
+ # HTML and JavaScript for the "Copy Code" button
8
+ copy_button_html = """
9
+ <script>
10
+ function copyCode(textareaId) {
11
+ const text = document.querySelector(`#${textareaId} textarea`).value;
12
+ navigator.clipboard.writeText(text).then(() => {
13
+ alert("Text copied to clipboard!");
14
+ }).catch(() => {
15
+ alert("Failed to copy text.");
16
+ });
17
+ }
18
+ </script>
19
+ """
20
+
21
  # Common functions
22
  def is_valid_url(url):
23
  """Checks if the string is a valid URL."""
 
228
  return code.strip()
229
 
230
  # Create the Gradio interface
231
+ with gr.Blocks() as demo:
232
  gr.HTML(copy_button_html) # Add the "Copy Code" script
233
 
234
  with gr.Tabs():