Overview

worldip

Simple WSGI app that shows your IP and geolocation info.

Uses WorldIP database from http://www.wipmania.com/

Installation

  1. Download worldip.sql.zip (SQL-format DB) from http://www.wipmania.com/en/base/
  2. Run ./wip2sqlite.sh. This will create worldip.db SQLite DB file. Alternatively run ./wip2pgsql.sh to create tables in PostgreSQL database named worldip (the database must already exist before running this script).
  3. Set up worldip.py to be served by mod_wsgi or uWSGI (or whatever you use for WSGI apps). You may need to install the dependencies (listed in requirements.txt pip requirements file) in virtualenv or somewhere in PYTHONPATH. By default it looks for SQLite DB, if you intend to use PostgreSQL, change DB URI at the end of the file.

API Usage

Human readable (text/plain MIME type) response:

$ curl http://example.org/

JSON response:

$ curl -H 'Accept: application/json' http://example.org/

YAML response (text/x-yaml MIME type is also accepted):

$ curl -H 'Accept: application/x-yaml' http://example.org/

JSONP response:

$ curl http://example.org/?callback=foobar

CORS requests are supported as well.