Download app.py from ohmcpatel/trial: direct link, hf CLI and curl.
- Browser
- Download file 831 Bytes
-
https://huggingface.co/spaces/ohmcpatel/trial/resolve/main/app.py
- Command line
-
hf download hf://spaces/ohmcpatel/trial/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ohmcpatel/trial/resolve/main/app.py
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() | |