From 458fce4a60e0f92cda7094134c9fbac939f1edea Mon Sep 17 00:00:00 2001 From: Siddhesh Agarwal Date: Thu, 6 Apr 2023 16:52:04 +0530 Subject: [PATCH] Added support for multiple IPs --- app.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index cf3850e..c2b3b1f 100644 --- a/app.py +++ b/app.py @@ -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 @@ -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]: