hack-ip-address / app.py
Kvikontent's picture
Update app.py
b66f72d verified
raw
history blame
2.34 kB
import streamlit as st
import requests
def get_ip():
response = requests.get('https://api64.ipify.org?format=json').json()
return response["ip"]
def get_location(ip_address):
response = requests.get(f'https://ipapi.co/{ip_address}/json/').json()
location_data = {
"ip": ip_address,
"city": response.get("city"),
"region": response.get("region"),
"country": response.get("country_name"),
"postalcode": response.get("postal"),
"latitude": response.get("latitude"),
"longitude": response.get("longitude"),
"timezone": response.get("timezone"),
"utc_offset": response.get("utc_offset"),
"country_calling_code": response.get("country_calling_code"),
"country_population": response.get("country_population")
}
return location_data
st.title("Hack any ip address and get info")
get = st.selectbox(
'Choose way to get ip address',
("Input", "Get yours")
)
if get == "Input":
ip = st.text_input("Enter IP address")
sub = st.button("Hack")
if sub:
data = get_location(ip)
if data:
st.write(f"""Information that we searched for this ip address: {data['ip']}
City: {data['city']}
Region: {data['region']}
Country: {data['country']}
Postal code: {data['postalcode']}
Latitude: {data['latitude']}
Longitude: {data['longitude']}
Timezone: {data['timezone']}
UTC Offset: {data['utc_offset']}
Country Calling Code: {data['country_calling_code']}
Country Population: {data['country_population']}""")
if get == "Get yours":
ip = get_ip()
sub = st.button("Hack")
if sub:
data = get_location(ip)
if data:
st.write(f"""Information that we searched for this ip address: {data['ip']}
City: {data['city']}
Region: {data['region']}
Country: {data['country']}
Postal code: {data['postalcode']}
Latitude: {data['latitude']}
Longitude: {data['longitude']}
Timezone: {data['timezone']}
UTC Offset: {data['utc_offset']}
Country Calling Code: {data['country_calling_code']}
Country Population: {data['country_population']}""")