Spaces:
Runtime error
Runtime error
| 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']}\n | |
| City: {data['city']}\n | |
| Region: {data['region']}\n | |
| Country: {data['country']}\n | |
| Postal code: {data['postalcode']}\n | |
| Latitude: {data['latitude']}\n | |
| Longitude: {data['longitude']}\n | |
| Timezone: {data['timezone']}\n | |
| UTC Offset: {data['utc_offset']}\n | |
| Country Calling Code: {data['country_calling_code']}\n | |
| Country Population: {data['country_population']}\n""") | |
| 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']}\n | |
| City: {data['city']}\n | |
| Region: {data['region']}\n | |
| Country: {data['country']}\n | |
| Postal code: {data['postalcode']}\n | |
| Latitude: {data['latitude']}\n | |
| Longitude: {data['longitude']}\n | |
| Timezone: {data['timezone']}\n | |
| UTC Offset: {data['utc_offset']}\n | |
| Country Calling Code: {data['country_calling_code']}\n | |
| Country Population: {data['country_population']}\n""") | |