Skip to main content

Flask-GeoIP ------------- Simple Flask extension for pygeoip.

Project description

**Author:** Jacob Magnusson. [Follow me on Twitter](https://twitter.com/jacobsvante_)

## About

This is a simple Flask extension for pygeoip. Not yet thoroughly tested, but has been working great for me so far.


## Installation

Install using `pip`...

pip install Flask-GeoIP

...or clone the project from github.

git clone https://github.com/jmagnusson/Flask-GeoIP.git


## Configuration


The GeoIP file that you want to use needs to be set in your config:

GEOIP_FILEPATH = '/path/to/geoip.dat'

You can change the caching method (default is 'STANDARD') that is used
by pygeoip:

GEOIP_CACHE = 'MEMORY_CACHE'

Then in the code you do:

from flask.ext.geoip import GeoIP
app = Flask(__name__)
app.config.from_pyfile('/path/to/myconfig.py')
geoip = GeoIP(app)
country = geoip.country_name_by_addr('1.2.3.4')

Or if using a factory function for creating your app:

from flask.ext.geoip import GeoIP
geoip = GeoIP()
...
app = create_app('/path/to/myconfig.py')
geoip.init_app(app)
country = geoip.country_name_by_addr('1.2.3.4')


## Documentation

This readme.


## Credits

Thanks go out to [maxmind](https://github.com/maxmind/geoip-api-c) and [appliedsec](https://github.com/appliedsec/pygeoip) for making these great libs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-GeoIP-0.1.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

Flask_GeoIP-0.1.3-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Flask-GeoIP-0.1.3.tar.gz.

File metadata

File hashes

Hashes for Flask-GeoIP-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2ec7a96e330b872178fa82c3f433bc96b63b384af429253c7b1d180fc3672a0a
MD5 f99c5643d82dc3c94a21c413b5d0eef3
BLAKE2b-256 e067ba5551f2e5a12c1d687e0ad8840eac5c4fba23cd1fe4e03e786081017f72

See more details on using hashes here.

File details

Details for the file Flask_GeoIP-0.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_GeoIP-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3567ba970b2a5c013953a965d3d88f955983955c65f3e9af12c9e5c28a218abe
MD5 79218d7b2b7576e01842526e57a662e4
BLAKE2b-256 4255f172aff8e9969ede5c0fa5d8e16f5275c2885477e1c36c8d30569f34c3f8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page