Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import requests | |
| def get_location(): | |
| try: | |
| response = requests.get("https://ipinfo.io/json") | |
| data = response.json() | |
| return { | |
| "City": data.get("city"), | |
| "Region": data.get("region"), | |
| "Country": data.get("country"), | |
| "Location (Lat, Long)": data.get("loc"), | |
| "IP Address": data.get("ip"), | |
| } | |
| except Exception as e: | |
| return {"Error": str(e)} | |
| st.title("π Find Your Location") | |
| st.write("This app fetches your location using your IP address.") | |
| if st.button("Get My Location"): | |
| location_data = get_location() | |
| st.json(location_data) | |