Skip to content

Commit

Permalink
remove api key from code
Browse files Browse the repository at this point in the history
  • Loading branch information
romain-fontugne committed Jan 30, 2025
1 parent 1c96c03 commit 1832624
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions psql/consumers/geolite_city.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
import urllib.request as request
from contextlib import closing

URL = 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=FzexWm0KCn5LZ12p&suffix=tar.gz'
URL = 'https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&suffix=tar.gz&license_key='


class GeoliteCity(object):

def __init__(self) -> None:

self.folder = appdirs.user_cache_dir('geolite', 'ihr')
self.dbfname = ''
self.reader = None

def download_database(self, overwrite=True):

url = URL
url = URL+API_KEY
os.makedirs(self.folder, exist_ok=True)
fname = '/geolite_city.tar.gz'

Expand All @@ -39,7 +39,7 @@ def download_database(self, overwrite=True):
for tar_fname in tar.getnames():
if tar_fname.endswith('.mmdb'):
self.dbfname = self.folder+'/'+tar_fname

tar.close()

def load_database(self):
Expand All @@ -62,6 +62,9 @@ def lookup(self, ip):

if __name__ == '__main__':

global API_KEY
API_KEY = os.environ["MAXMIND_API_KEY"]

gc = GeoliteCity()
gc.download_database(overwrite=False)
gc.load_database()
Expand Down

0 comments on commit 1832624

Please sign in to comment.