Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import socket
|
| 3 |
+
|
| 4 |
+
# Function to resolve the IP address from a URL
|
| 5 |
+
def get_ip_address_from_url(url):
|
| 6 |
+
try:
|
| 7 |
+
# Get the IP address of the domain
|
| 8 |
+
ip_address = socket.gethostbyname(url)
|
| 9 |
+
return ip_address
|
| 10 |
+
except socket.gaierror:
|
| 11 |
+
st.error("Invalid URL or Unable to resolve IP address.")
|
| 12 |
+
return None
|
| 13 |
+
|
| 14 |
+
# Streamlit app
|
| 15 |
+
def main():
|
| 16 |
+
st.title("Get IP Address from URL")
|
| 17 |
+
|
| 18 |
+
# Input field to enter a URL
|
| 19 |
+
url = st.text_input("Enter the URL of the website (e.g., google.com)")
|
| 20 |
+
|
| 21 |
+
# Button to get the IP address
|
| 22 |
+
if st.button("Get IP Address"):
|
| 23 |
+
if url:
|
| 24 |
+
ip_address = get_ip_address_from_url(url)
|
| 25 |
+
if ip_address:
|
| 26 |
+
st.success(f"The IP Address for {url} is: {ip_address}")
|
| 27 |
+
else:
|
| 28 |
+
st.warning("Please enter a valid URL.")
|
| 29 |
+
|
| 30 |
+
if __name__ == "__main__":
|
| 31 |
+
main()
|