@app.route('/<ip_addr>')
def lookup_ip(ip_addr):
	try: 
		ip = ipaddress.ip_address(ip_addr)
	except __HOLE__:
		abort(400)
	if ip.version == 4:
		gi_city = GI_CITY
		gi_org = GI_ORG
		r = gi_city.record_by_addr(ip.exploded)
		org = gi_org.name_by_addr(ip.exploded)	
	else:
		gi_city = GI_CITY_V6
		gi_org = GI_ORG_V6
		r = gi_city.record_by_addr_v6(ip.exploded)
		org = gi_org.name_by_addr_v6(ip.exploded)	
	if org:
		m = re.search(r'^(AS[0-9]+) (.+)$', org)
		if m and isinstance(r, dict):
			r['asn'] = m.group(1)
			r['org'] = m.group(2)
	return Response(json.dumps(r), mimetype='application/json')
dataset/ETHPy150Open kz26/balise/main.py/lookup_ip