Spaces:
Running
Running
BraydenMoore
commited on
Commit
·
a38f152
1
Parent(s):
7637822
Update main.py
Browse files
main.py
CHANGED
@@ -43,9 +43,9 @@ def get_location(ip):
|
|
43 |
if location and 'location' in location:
|
44 |
return {'country': location['country']['names']['en'],
|
45 |
'city': location['city']['names']['en'] if 'city' in location else '',
|
46 |
-
'region': location['subdivisions'][0]['names']['en'] if
|
47 |
'loc': str(location['location']['longitude']) + ',' + str(location['location']['latitude']),
|
48 |
-
'timezone': location['location']['time_zone']}
|
49 |
|
50 |
def latlon_to_pixel(loc):
|
51 |
latitude = float(loc.split(',')[0])
|
@@ -99,6 +99,7 @@ def index():
|
|
99 |
session['current_feed'] = feed
|
100 |
|
101 |
ip = ''.join(url.split('//')[-1]).split(':')[0]
|
|
|
102 |
info = get_location(ip)
|
103 |
country = info['country']
|
104 |
name = (info['city'] + ", " + info['region'] + ", " + country).lower()
|
|
|
43 |
if location and 'location' in location:
|
44 |
return {'country': location['country']['names']['en'],
|
45 |
'city': location['city']['names']['en'] if 'city' in location else '',
|
46 |
+
'region': location['subdivisions'][0]['names']['en'] if 'subdivisions' in location else '',
|
47 |
'loc': str(location['location']['longitude']) + ',' + str(location['location']['latitude']),
|
48 |
+
'timezone': location['location']['time_zone'] if 'time_zone' in location else ''}
|
49 |
|
50 |
def latlon_to_pixel(loc):
|
51 |
latitude = float(loc.split(',')[0])
|
|
|
99 |
session['current_feed'] = feed
|
100 |
|
101 |
ip = ''.join(url.split('//')[-1]).split(':')[0]
|
102 |
+
print('IP:',ip)
|
103 |
info = get_location(ip)
|
104 |
country = info['country']
|
105 |
name = (info['city'] + ", " + info['region'] + ", " + country).lower()
|