Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,4 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
st.markdown("""
|
| 4 |
-
# Level 3 Internet Communication Protocols
|
| 5 |
-
|
| 6 |
-
# 📧 SMTP
|
| 7 |
-
- Simple Mail Transfer Protocol: The standard protocol used for sending email messages over the internet. It defines how email clients and servers communicate and deliver messages.
|
| 8 |
-
|
| 9 |
-
# 💬 XMPP
|
| 10 |
-
- Extensible Messaging and Presence Protocol: A communication protocol used for instant messaging, presence information, and contact list management. It allows for interoperability between different messaging platforms.
|
| 11 |
-
|
| 12 |
-
# 🌐 HTTP
|
| 13 |
-
- **Hypertext Transfer Protocol**: The foundation of data communication on the World Wide Web. It defines how web browsers and servers exchange information, enabling the retrieval and display of web pages.
|
| 14 |
-
""")
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
st.markdown("""#Code:
|
| 18 |
-
|
| 19 |
-
```
|
| 20 |
-
import streamlit as st
|
| 21 |
import smtplib
|
| 22 |
from email.message import EmailMessage
|
| 23 |
import http.client
|
|
@@ -66,55 +47,4 @@ st.header("HTTP Demo 🌐")
|
|
| 66 |
url = st.text_input("URL to fetch", value="http://example.com")
|
| 67 |
if st.button("Fetch URL"):
|
| 68 |
result = http_client(url)
|
| 69 |
-
st.text_area("Response", value=result, height=250)
|
| 70 |
-
```
|
| 71 |
-
|
| 72 |
-
```
|
| 73 |
-
import streamlit as st
|
| 74 |
-
from slixmpp import ClientXMPP
|
| 75 |
-
from slixmpp.exceptions import IqError, IqTimeout
|
| 76 |
-
|
| 77 |
-
class SendMsgBot(ClientXMPP):
|
| 78 |
-
def __init__(self, jid, password, recipient, message):
|
| 79 |
-
ClientXMPP.__init__(self, jid, password)
|
| 80 |
-
self.recipient = recipient
|
| 81 |
-
self.msg = message
|
| 82 |
-
self.add_event_handler("session_start", self.session_start)
|
| 83 |
-
|
| 84 |
-
def session_start(self, event):
|
| 85 |
-
self.send_presence()
|
| 86 |
-
self.get_roster()
|
| 87 |
-
try:
|
| 88 |
-
self.send_message(mto=self.recipient, mbody=self.msg, mtype='chat')
|
| 89 |
-
except IqError as err:
|
| 90 |
-
st.error(f"Could not send message: {err.iq['error']['text']}")
|
| 91 |
-
self.disconnect()
|
| 92 |
-
except IqTimeout:
|
| 93 |
-
st.error("Server not responding")
|
| 94 |
-
self.disconnect()
|
| 95 |
-
else:
|
| 96 |
-
st.success("Message sent successfully!")
|
| 97 |
-
self.disconnect()
|
| 98 |
-
|
| 99 |
-
# XMPP Section in Streamlit UI
|
| 100 |
-
st.header("XMPP Demo 💬")
|
| 101 |
-
jid = st.text_input("Jabber ID", value="user@server.com")
|
| 102 |
-
password = st.text_input("Password", type="password")
|
| 103 |
-
recipient = st.text_input("Recipient JID", value="friend@server.com")
|
| 104 |
-
message = st.text_area("Message to send")
|
| 105 |
-
|
| 106 |
-
if st.button("Send XMPP Message"):
|
| 107 |
-
if jid and password and recipient and message:
|
| 108 |
-
xmpp = SendMsgBot(jid, password, recipient, message)
|
| 109 |
-
xmpp.connect()
|
| 110 |
-
xmpp.process(forever=False)
|
| 111 |
-
else:
|
| 112 |
-
st.error("Please fill in all fields.")
|
| 113 |
-
|
| 114 |
-
```
|
| 115 |
-
|
| 116 |
-
""")
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
| 1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import smtplib
|
| 3 |
from email.message import EmailMessage
|
| 4 |
import http.client
|
|
|
|
| 47 |
url = st.text_input("URL to fetch", value="http://example.com")
|
| 48 |
if st.button("Fetch URL"):
|
| 49 |
result = http_client(url)
|
| 50 |
+
st.text_area("Response", value=result, height=250)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|