File size: 398 Bytes
ed11779
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import requests

def get_current_location():
    """Get the user's current location using an IP geolocation API."""
    try:
        response = requests.get("https://ipapi.co/json/")
        data = response.json()
        return data["latitude"], data["longitude"]
    except:
        # Default to a fixed location if geolocation fails
        return 40.7128, -74.0060  # New York City coordinates