Skip to content

moominrasheed/geoip2-geolocation-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeoIP2 Geolocation API

This is a Flask web application that provides geolocation information for a given IP address using MaxMind's GeoIP2 databases.

Setup

  1. Install dependencies using pip:
pip install flask maxminddb
  1. Download the GeoIP2 databases from MaxMind's website:
  1. Update the paths to the downloaded databases in the city_db_path, country_db_path, and asn_db_path variables in the app.py file:
city_db_path = 'GeoLite2-City.mmdb'
country_db_path = 'GeoLite2-Country.mmdb'
asn_db_path = 'GeoLite2-ASN.mmdb'
  1. Start the Flask application:
python app.py

Deployment

The GeoIP2 Geolocation API can be deployed in various ways, depending on your requirements and preferences. Here are a few options:

Local Development

For local development, you can simply run the Flask application on your local machine using the python app.py command as mentioned in the setup section.

Virtual Environment

You can create a virtual environment for the Flask application and deploy it in a virtual environment. Here's an example:

  1. Create and activate a virtual environment:
python -m venv myenv
source myenv/bin/activate  # On Windows: myenv\Scripts\activate
  1. Install dependencies inside the virtual environment:
pip install flask maxminddb
  1. Update the paths to the downloaded databases in the city_db_path, country_db_path, and asn_db_path variables in the app.py file.

  2. Start the Flask application:

python app.py

Docker

You can also deploy the GeoIP2 Geolocation API in a Docker container. Here's an example:

  1. Install Docker on your machine following the official Docker documentation.

  2. Build a Docker image from the provided Dockerfile:

docker build -t geoip2-api .
  1. Run a Docker container from the built image:
docker run -p 5000:5000 -d geoip2-api

This will run the Flask application inside a Docker container, and you can access it at http://localhost:5000 in your web browser.

API Endpoint

[API endpoint details here]

License

This project is licensed under the MIT License. See LICENSE for more information.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages