Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

frascoweb/frasco-geoip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frasco-Geoip

Uses pygeoip and Maxmind's databases to geolocate the current visitor. Provides command to download the databases. The session is used as a cache.

Installation

pip install frasco-geoip

Setup

Feature name: geoip

Options:

  • auto_geolocate: whether to geolocate the visitor before every requests (default: True)
  • country_db: filename of the country database (default: GeoIP.dat)
  • city_db: filename of the city database (default: GeoLiteCity.dat)

Downloading the databases

You will need to download Maxmind's GeoLite databases to be able to use this feature. They are free and available from http://dev.maxmind.com/geoip/geoip2/geolite2/.

This feature provides a command to easily download them:

$ frasco geoip dlcountries # downloads the country database
$ frasco geoip dlcities # downloads the city database

Actions

geolocate_country

Geolocates the country of the current visitor using the remote_addr of the request.

Options:

  • addr (default): the ip to geolocate (optional, default is the request's remote_addr)

Returns the country code.
Default variable assignment: $geo_country_code

geolocate_city

Geolocates the city of the current visitor using the remote_addr of the request.

Options:

  • addr (default): the ip to geolocate (optional, default is the request's remote_addr)

Returns the city record.
Default variable assignment: $geo_city

clear_geo_cache

Clears the cached values in the session

Debugging

To make things easier, in debug mode the ip address of the visitor can be overrided using the __geoaddr query parameter.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages