Spaces:
Sleeping
Sleeping
File size: 542 Bytes
9d6ac78 7fa788a 9d6ac78 7fa788a 9d6ac78 7fa788a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import streamlit as st
import streamlit.components.v1 as components
# Define the JavaScript code
js_code = """
function myFunction() {
// Perform your desired operation here
var result = "This is the result from JavaScript";
return result;
}
"""
# Create a custom component with the JavaScript code
mycomponent = components.declare_component("mycomponent", js_code)
# Add a button to trigger the JavaScript function
if st.button("Run JavaScript Function"):
result = mycomponent()
st.markdown(f"The result is: {result}") |