visualize in the map where you are using ip address
Drop files here
or click to upload
import pandas as pd
import requests
st.title('Map Visualization from IP Address')
ip_address = st.text_input('Enter an IP Address:', '8.8.8.8')
if ip_address:
response = requests.get(f'https://ipapi.co/{ip_address}/json/')
data = response.json()
if response.status_code == 200:
st.write(f'IP Address: {data.get("ip")}')
st.write(f'City: {data.get("city")}')
st.write(f'Region: {data.get("region")}')
st.write(f'Country: {data.get("country")}')
st.write(f'Latitude: {data.get("latitude")}')
st.write(f'Longitude: {data.get("longitude")}')
map_data = pd.DataFrame([
{
'lat': data.get('latitude'),
'lon': data.get('longitude')
}
])
st.map(map_data)
else:
st.write('Error: Invalid IP address or unable to fetch data.')
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?