Skip to main content

getting user geolocation for Flask

Project description

Flask-Geolocation

Flask-Geolocation aims to help get geolocation informaton for Flask app. It only supports Maxmind IP Database now.

Installation

install the extension with pip

pip install flask-geolocation

Usage

initialization

from flask-geolocation import GeoManager

# ip_data_path can be a relative path to your project root.
geo_manager = GeoManager("ip_data_path")
geo_manager.init_app(app)

get geolocation related info with flask global variable current_geo

from flask-geolocation import current_geo

current_geo.ip
current_geo.country_symbol
current_geo.country_name
current_geo.timezone

you can also use current_geo in template

<html en="lang">
  <head>
  </head>
  <body>
    <p>ip: {{current_geo.ip}}</p>
    <p>country_symbol: {{current_geo.country_symbol}}</p>
    <p>country_name: {{current_geo.country_name}}</p>
    <p>timezone: {{current_geo.timezone}}</p>
  </body>
</html>

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-Geolocation-0.1.0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Flask_Geolocation-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file Flask-Geolocation-0.1.0.tar.gz.

File metadata

  • Download URL: Flask-Geolocation-0.1.0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for Flask-Geolocation-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e471aa1480e5044d6d8efcaba5b8216cd815a94d854c12558e1da853a0d7b92e
MD5 0cda8bb8e028c9fd2e2eda67eaa4ad73
BLAKE2b-256 d5bcd0d3bde4b3341d075f28b4537ff1ad1592c70ef82056b800073909ee908c

See more details on using hashes here.

File details

Details for the file Flask_Geolocation-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_Geolocation-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1be9120bb4518b8cdd6f1051a92325fbeba25b3a8d95accc45a3a88a179f91e8
MD5 d5899cd0ed0bc594e42c0b6a7d3ff91f
BLAKE2b-256 4ff35f7fef72ec79d3707cf2167fbb3e146503c013a343ecc624a13f7d51c569

See more details on using hashes here.

Supported by

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