A Flask web application that detects the user's geographical location based on their public IP address and displays it on an interactive map using Folium. The app fetches location details such as latitude, longitude, and a human-readable address, providing a visual display centered on the user's current location.
- π IP-based Location Detection: Automatically retrieves the user's geographical location using their public IP address.
- πΊοΈ Interactive Map: Displays the user's location on a dynamic map powered by Folium.
- π Location Information: Shows precise details like latitude, longitude, and an approximate address.
app.py
: The main Flask application that runs the web server and generates the location-based map.gps.py
: A helper script for fetching and printing the userβs location (IP-based) for debugging purposes.templates/
: Contains the HTML files used to render the front end.static/
: A directory reserved for static files (e.g., images, saved locations, CSS files) that can be used in future projects.
- Git: Version control system to clone the repository.
- Python 3.x: Required for running the application.
- Pip: Python's package manager to install dependencies.
python3 -m venv venv
source venv/bin/activate
python -m venv venv
.\venv\Scripts\activate
git clone https://github.com/PoojanDoshi11/get_location.git
cd get_location
pip install -r requirements.txt
python3 app.py
python app.py
- Open your browser and navigate to http://127.0.0.1:5000/ to view the interactive map showing your location.
- The IP-based location detection relies on third-party services, which may not provide accurate geolocation. The results can vary by up to 5 km, especially if you are using a VPN or proxy.
- If the application fails to retrieve your IP-based location, make sure you have an active internet connection. The app queries external geolocation services that require internet access.
- Some corporate or secured networks might block access to geolocation APIs, leading to errors in retrieving location data. In this case, try running the app on a different network or contact the network administrator to whitelist the necessary services.
- If requirements.txt is missing or incomplete, you might encounter errors related to missing Python packages. Ensure that all dependencies are listed and installed correctly with:
pip install -r requirements.txt
- If you encounter issues with missing libraries, ensure that the virtual environment is activated before running the app:
- Linux/macOS: source venv/bin/activate
- Windows: .\venv\Scripts\activate