Skip to content

Commit

Permalink
Added support for multiple IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddhesh-Agarwal committed Apr 6, 2023
1 parent 81eb77b commit 458fce4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


def get_domain(url: str) -> str:
url = url.lower()
url = url.replace("https://", "").replace("http://", "").replace("www.", "")
domain = url.split("/", 1)[0]
return domain
Expand Down Expand Up @@ -60,13 +61,13 @@ def get_location(ip_address: str) -> dict:
st.success(ip_address)
except socket.gaierror:
st.error("Invalid URL")

with st.spinner("Checking database..."):
# check if domain exists
if collection.find_one({"domain": domain}):
st.info(f"Domain already exists in the database")
if collection.find_one({"domain": domain, "ip_address": ip_address}):
st.info(f"Data already exists in the database")
else:
collection.insert_one({"domain": domain, "ip_address": ip_address})
st.info(f"Domain added to the database")
st.info(f"Data added to the database")


with tabs[1]:
Expand Down

0 comments on commit 458fce4

Please sign in to comment.