Repository: gradio-app/gradio

Issue:
Copy of code blocks does not work for LAN access
### Describe the bug

When I access my application on the LAN and click the copy button in the code block, an error is reported
If I access localhost, the problem will no longer exist
Please fix it as soon as possible
![image](https://github.com/gradio-app/gradio/assets/46100050/70c619a8-e9c8-4705-a476-71abe9f46574)


### Is there an existing issue for this?

- [X] I have searched the existing issues

### Reproduction

.launch(server_name="0.0.0.0" 

### Screenshot

_No response_

### Logs

```shell
properties of undefined (reading 'writeText')
    at HTMLButtonElement.<anonymous> (ChatBot.svelte:57:25)
(匿名) @ ChatBot.svelte:57
ChatBot.svelte:5
```


### System Info

```shell
no
```


### Severity

annoying


Discussion:
This error is due to the browser security policy that does not allow the `navigator.clipboard.writeText()` method when accessing on a LAN. This is to prevent malicious websites from abusing the clipboard function.

The reason it works properly when accessed locally is that the local environment is considered a trusted environment and therefore the clipboard API can be used.

To solve this problem, you can use a library or technology such as `clipboard.js`, which provides cross-browser clipboard functionality and is not restricted by browser security policies. The following is sample code for using `clipboard.js`:

1. First, you need to introduce the `clipboard.js` library. You can download the library from the official website, or use the CDN link: ``clipboard.js`:
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>
```

2. Then, in your code, replace the following code:
```javascript
navigator.clipboard.writeText(code_node.innerText.trimEnd()).
```
for:
```javascript
const clipboard = new ClipboardJS(button, {
  text: function() {
    return code_node.innerText.trimEnd().
  }
}).
```

Make sure you have properly introduced the `clipboard.js` library and added it to the handler for the button click event.

By using `clipboard.js`, you can use the clipboard functionality properly in a LAN environment while avoiding the restrictions of browser security policies.

Translated with www.DeepL.com/Translator (free version)
Hi @Kilig947 it looks like you are using an older version of Gradio. Can you confirm if this is still an issue in the latest version of `gradio` (3.32)?
> Hi @Kilig947 it looks like you are using an older version of Gradio. Can you confirm if this is still an issue in the latest version of `gradio` (3.32)?
Is drawing HTML code no longer supported in 3.32.0 chatbot? If I throw the HTML code to chatbot, it will display it directly in source code 🥲 🥲 🥲 🥲 🥲
 
![image](https://github.com/gradio-app/gradio/assets/46100050/1bfd935d-d936-4468-9bd9-2f53e80fac4b)
![image](https://github.com/gradio-app/gradio/assets/46100050/93e90582-c775-4637-b145-0e749cede75c)

demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name=f"{func_box.ipaddr()}", share=True, server_port=PORT, auth=AUTHENTICATION)
The start-up parameters are as above, and when the copy button is clicked, no error is reported, but the copy is not successful either🥲

![image](https://github.com/gradio-app/gradio/assets/46100050/28b23e35-a0fc-4ab2-b905-b461d1bb3e6e)

	(Light theme): http://localhost:7891
	(dark theme): http://10.13.78.56:7891/? __theme=dark

Both in 3.28.3 and 3.32.0, when I visit http://localhost:7891, the copy button works fine, but when I visit http://10.13.78.56:7891/? __theme=dark, the copy button does not work properly

> demo.queue(concurrency_count=CONCURRENT_COUNT).launch(server_name=f"{func_box.ipaddr()}", share=True, server_port=PORT, auth=AUTHENTICATION) The start-up parameters are as above, and when the copy button is clicked, no error is reported, but the copy is not successful either🥲
> 
> ![image](https://user-images.githubusercontent.com/46100050/240467518-28b23e35-a0fc-4ab2-b905-b461d1bb3e6e.png)



Resolving patch:
diff --git a/demo/chatbot_simple/run.py b/demo/chatbot_simple/run.py
--- a/demo/chatbot_simple/run.py
+++ b/demo/chatbot_simple/run.py
@@ -2,6 +2,15 @@
 import random
 import time
 
+md = """This is some code:
+
+<h1>hello</h1>
+
+```py
+def fn(x, y, z):
+    print(x, y, z)
+"""
+
 with gr.Blocks() as demo:
     chatbot = gr.Chatbot()
     msg = gr.Textbox()
@@ -9,7 +18,7 @@
 
     def respond(message, chat_history):
         bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
-        chat_history.append((message, bot_message))
+        chat_history.append((message, md))
         time.sleep(1)
         return "", chat_history
 


Test patch: