Hint
Start by creating a basic Streamlit layout:
import streamlit as st
st.title("IP Address Locator")
ip = st.text_input("Enter IP Address")
Now think: how can you look up information about that IP?
Try using the requests
library and an IP geolocation API like http://ip-api.com/json/
:
import requests
url = f"http://ip-api.com/json/{ip}"
response = requests.get(url)
data = response.json()
Once you have the data, check if the response was successful, then display fields like:
data['country']
data['city']
data['lat']
,data['lon']
And if you want to show a map, use:
st.map([{"lat": data["lat"], "lon": data["lon"]}])