trial / app.py
ohmcpatel's picture
Update app.py
af0a2a3 verified
raw
history blame contribute delete
831 Bytes
import streamlit as st
def main():
st.title('Message Receiver')
# Display a placeholder for the received message
received_message_placeholder = st.empty()
# JavaScript code to handle messages received from the parent iframe
js_code = """
<script>
// Function to handle messages received from the parent iframe
const receiveMessageFromParent = (event) => {
// Update the Streamlit title with the received message
document.title = 'Message Receiver - ' + event.data.message;
};
// Add event listener to listen for messages from the parent iframe
window.addEventListener('message', receiveMessageFromParent);
</script>
"""
# Write the JavaScript code to the Streamlit app
st.write(js_code, unsafe_allow_html=True)
if __name__ == '__main__':
main()