Giter Club home page Giter Club logo

geodude's Introduction

geodude

WSGI application that uses geolocation to determine visitors' countries based on their IP address.

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'; }

/country.json

{"country_name": "United States", "country_code": "US"}

Anything else

{"error": "Function not supported."}

Developer Setup

  1. Clone the repo: git clone git://github.com/mozilla/geodude.git

  2. Recommended: Create a virtualenv and activate it.

  3. Install development dependencies using pip: pip install -r requirements/dev.txt

  4. Download the free MaxMind GeoLite Country database using the download_db command: ./manage.py download_db

  5. 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.

download_db

Usage: ./manage.py download_db

Downloads the free MaxMind GeoLite Country database and unzips it in the current directory to GeoIP.dat.

test

Usage: ./manage.py test

Runs the test suite.

License

geodude is released under the Apache License, Version 2.0. See the LICENSE file for more info.

geodude's People

Contributors

wraithan avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.