ohmcpatel commited on
Commit
af0a2a3
·
verified ·
1 Parent(s): d6d21f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -3,21 +3,20 @@ import streamlit as st
3
  def main():
4
  st.title('Message Receiver')
5
 
6
- # JavaScript code to handle messages received from the iframe
 
 
 
7
  js_code = """
8
  <script>
9
- // Function to handle messages received from the iframe
10
- const receiveMessageFromIframe = (event) => {
11
- // Check the origin of the message to ensure security
12
- if (event.origin !== 'http://origin_of_your_iframe') {
13
- return;
14
- }
15
  // Update the Streamlit title with the received message
16
- document.title = 'Message Receiver - ' + event.data;
17
  };
18
 
19
- // Add event listener to listen for messages from the iframe
20
- window.addEventListener('message', receiveMessageFromIframe);
21
  </script>
22
  """
23
 
 
3
  def main():
4
  st.title('Message Receiver')
5
 
6
+ # Display a placeholder for the received message
7
+ received_message_placeholder = st.empty()
8
+
9
+ # JavaScript code to handle messages received from the parent iframe
10
  js_code = """
11
  <script>
12
+ // Function to handle messages received from the parent iframe
13
+ const receiveMessageFromParent = (event) => {
 
 
 
 
14
  // Update the Streamlit title with the received message
15
+ document.title = 'Message Receiver - ' + event.data.message;
16
  };
17
 
18
+ // Add event listener to listen for messages from the parent iframe
19
+ window.addEventListener('message', receiveMessageFromParent);
20
  </script>
21
  """
22