File size: 1,033 Bytes
7f93673
4658994
7f93673
 
4658994
7f93673
4658994
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f93673
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
import urllib.parse

def main():
    st.title("Text Copy Demo")
    
    # Create a text input
    text_to_copy = st.text_input("Enter text to copy:", "Hello, World!")
    
    # Encode the text for URL
    encoded_text = urllib.parse.quote(text_to_copy)
    
    # You'll need to replace this with your actual hosted HTML file URL
    hosted_html_file = "https://your-domain.com/copy.html"
    iframe_url = f"{hosted_html_file}?copy={encoded_text}"
    
    # Create the iframe with some styling
    st.markdown(
        f"""
        <iframe 
            src="{iframe_url}" 
            style="border: none; width: 60px; height: 45px; overflow: hidden;"
        ></iframe>
        """, 
        unsafe_allow_html=True
    )
    
    # Add some instructions
    st.markdown("""
    ### Instructions:
    1. Enter your text in the input field above
    2. Click the clipboard button to copy the text
    3. The button will show a checkmark when the text is copied
    """)

if __name__ == "__main__":
    main()