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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Flask-Geolocation-0.1.1.tar.gz.
File metadata
- Download URL: Flask-Geolocation-0.1.1.tar.gz
- Upload date:
- Size: 2.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7ba85705a69abe8acfa5eab91ca0bac9e33353771a087ca426c9d88ea5d0c92
|
|
| MD5 |
ad027410a8be827f2aa41867d249b3ca
|
|
| BLAKE2b-256 |
e2b9494925ce0e68ca10af3af681c2abd6442f8bfcde4301e13cc0922c360e65
|
File details
Details for the file Flask_Geolocation-0.1.1-py3-none-any.whl.
File metadata
- Download URL: Flask_Geolocation-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59b954216c33adab18640e657de66c7eb78d7cc519a5d564327039f9dfc5ab49
|
|
| MD5 |
f00b1f0de3d5f13e192b161e884e8388
|
|
| BLAKE2b-256 |
3b66cb80ae8e4dba45566d0f2ee52d9b7145fc29176a683b00ad9f74297382c0
|