Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,61 +1,37 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
import time
|
4 |
|
5 |
def main():
|
6 |
-
st.title("
|
7 |
|
8 |
-
# Create a
|
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 |
-
col1, col2 = st.columns(2)
|
37 |
-
|
38 |
-
with col1:
|
39 |
-
st.subheader("HTML Textarea")
|
40 |
-
# Render the HTML component
|
41 |
-
html(html_code, height=200)
|
42 |
-
|
43 |
-
with col2:
|
44 |
-
st.subheader("Streamlit Textarea")
|
45 |
-
# Streamlit textarea that shows the synced content
|
46 |
-
synced_text = st.text_area(
|
47 |
-
"Synced content (updates every second):",
|
48 |
-
value=st.session_state.text_value,
|
49 |
-
height=150,
|
50 |
-
key="synced_textarea"
|
51 |
-
)
|
52 |
-
|
53 |
-
# Show the current value for debugging
|
54 |
-
st.subheader("Current Value in Session State:")
|
55 |
-
st.code(st.session_state.text_value)
|
56 |
-
|
57 |
-
# Add a note about the sync behavior
|
58 |
-
st.info("The content from the HTML textarea will sync to the Streamlit textarea every second. Try typing in the HTML textarea and watch the Streamlit textarea update!")
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
+
import urllib.parse
|
|
|
3 |
|
4 |
def main():
|
5 |
+
st.title("Text Copy Demo")
|
6 |
|
7 |
+
# Create a text input
|
8 |
+
text_to_copy = st.text_input("Enter text to copy:", "Hello, World!")
|
9 |
+
|
10 |
+
# Encode the text for URL
|
11 |
+
encoded_text = urllib.parse.quote(text_to_copy)
|
12 |
+
|
13 |
+
# You'll need to replace this with your actual hosted HTML file URL
|
14 |
+
hosted_html_file = "https://your-domain.com/copy.html"
|
15 |
+
iframe_url = f"{hosted_html_file}?copy={encoded_text}"
|
16 |
+
|
17 |
+
# Create the iframe with some styling
|
18 |
+
st.markdown(
|
19 |
+
f"""
|
20 |
+
<iframe
|
21 |
+
src="{iframe_url}"
|
22 |
+
style="border: none; width: 60px; height: 45px; overflow: hidden;"
|
23 |
+
></iframe>
|
24 |
+
""",
|
25 |
+
unsafe_allow_html=True
|
26 |
+
)
|
27 |
+
|
28 |
+
# Add some instructions
|
29 |
+
st.markdown("""
|
30 |
+
### Instructions:
|
31 |
+
1. Enter your text in the input field above
|
32 |
+
2. Click the clipboard button to copy the text
|
33 |
+
3. The button will show a checkmark when the text is copied
|
34 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
main()
|