Spaces:
Sleeping
Sleeping
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}") |