WSGI application that uses geolocation to determine visitors’ countries based on
their IP address.
Configuration
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
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
/country.js
function geoip_country_code() { return 'US'; }
function geoip_country_name() { return 'United States'; }
Copy the settings.py-dist file to settings.py:
cp settings.py-dist settings.py
The default values in this settings file should be fine for local
development.
manage.py Commands
runserver
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.
test_ip
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.
geodude
WSGI application that uses geolocation to determine visitors’ countries based on their IP address.
Configuration
Geodude supports either the GeoIP database format or Maxmind’s MMDB format. Indicate which to use by setting
GEO_DB_FORMATin settings.py to either'geoip'or'mmdb'.Endpoints
Endpoints only return the visitors location unless you turn on
ALLOW_POSTin the settings. When that setting is enabled you can POST to the following endpoints with this body:/country.js
/country.json
Anything else
Developer Setup
Clone the repo:
git clone git://github.com/mozilla/geodude.gitRecommended: Create a virtualenv and activate it.
Install development dependencies using
pip:pip install -r requirements/dev.txtDownload the free MaxMind GeoLite Country database using the
download_dbcommand:./manage.py download_dbCopy the
settings.py-distfile tosettings.py:cp settings.py-dist settings.pyThe default values in this settings file should be fine for local development.
manage.pyCommandsrunserver
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.1as the IP address.test_ip
Usage:
./manage.py test_ip ip_addressRuns a mock request against the application, using the given IP address as the remote address. Useful for local testing.
download_db
Usage:
./manage.py download_dbDownloads the free MaxMind GeoLite Country database and unzips it in the current directory to
GeoIP.dat.test
Usage:
./manage.py testRuns the test suite.
NewRelic Support
A preconfigured
newrelic.inifile is included. To enable NewRelic you need to setNEW_RELIC_LICENSE_KEYandNEW_RELIC_APP_NAMEin the environment.License
geodude is released under the Apache License, Version 2.0. See the
LICENSEfile for more info.