Socket
Socket
Sign inDemoInstall

Flask-GeoIP

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    Flask-GeoIP

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


Maintainers
1

Readme

Author: Jacob Magnusson. Follow me on Twitter

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 and appliedsec for making these great libs.

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc