File size: 664 Bytes
49d4f7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)