Rahulk2197 commited on
Commit
49d4f7c
·
verified ·
1 Parent(s): 111b251

Rename app,py to app.py

Browse files
Files changed (2) hide show
  1. app,py +0 -0
  2. app.py +24 -0
app,py DELETED
File without changes
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ def get_location():
5
+ try:
6
+ response = requests.get("https://ipinfo.io/json")
7
+ data = response.json()
8
+ return {
9
+ "City": data.get("city"),
10
+ "Region": data.get("region"),
11
+ "Country": data.get("country"),
12
+ "Location (Lat, Long)": data.get("loc"),
13
+ "IP Address": data.get("ip"),
14
+ }
15
+ except Exception as e:
16
+ return {"Error": str(e)}
17
+
18
+ st.title("📍 Find Your Location")
19
+
20
+ st.write("This app fetches your location using your IP address.")
21
+
22
+ if st.button("Get My Location"):
23
+ location_data = get_location()
24
+ st.json(location_data)