WSGI application that uses geolocation to determine visitors' countries based on their IP address.
Geodude supports either the GeoIP database format or Maxmind's MMDB
format. Indicate which to use by setting GEO_DB_FORMAT
in
settings.py to either 'geoip'
or 'mmdb'
.
Endpoints only return the visitors location unless you turn on ALLOW_POST
in
the settings. When that setting is enabled you can POST to the following
endpoints with this body:
ip=0.0.0.0
function geoip_country_code() { return 'US'; }
function geoip_country_name() { return 'United States'; }
{"country_name": "United States", "country_code": "US"}
{"error": "Function not supported."}
-
Clone the repo:
git clone git://github.com/mozilla/geodude.git
-
Recommended: Create a virtualenv and activate it.
-
Install development dependencies using
pip
:pip install -r requirements/dev.txt
-
Download the free MaxMind GeoLite Country database using the
download_db
command:./manage.py download_db
-
Copy the
settings.py-dist
file tosettings.py
:cp settings.py-dist settings.py
The default values in this settings file should be fine for local development.
Usage: ./manage.py runserver [port=8000]
Starts the development server. Optionally takes a port to run on; the default is
port 8000. Not all that useful, as all local requests will use 127.0.0.1
as
the IP address.
Usage: ./manage.py test_ip ip_address
Runs a mock request against the application, using the given IP address as the remote address. Useful for local testing.
Usage: ./manage.py download_db
Downloads the free MaxMind GeoLite Country database and unzips it in
the current directory to GeoIP.dat
.
Usage: ./manage.py test
Runs the test suite.
A preconfigured newrelic.ini
file is included. To enable NewRelic
you need to set NEW_RELIC_LICENSE_KEY
and NEW_RELIC_APP_NAME
in
the environment.
geodude is released under the Apache License, Version 2.0. See
the LICENSE
file for more info.