@decorators.json_view
@account_decorators.login_required
def hostname_geoip(request):
    """AJAX method
    Retrieves the location of the given hostname using the GEO IP services.

    :param request: HTTP request
    :return: JSON object, { latitude: $lat, longitude: $lng }
    """
    # noinspection PyUnusedLocal
    hostname = None

    if 'hostname' in request.GET:
        hostname = request.GET['hostname']
    elif 'hostname' in request.POST:
        hostname = request.POST['hostname']
    else:
        json_data = json.loads(request.body)
        if 'hostname' in json_data:
            hostname = json_data['hostname']
        else:
            raise exceptions.BadRequest(
                "'hostname' not found as a parameter of the request."
            )

    host_ip = socket.gethostbyname(hostname)
    lat, lng = gis.get_remote_user_location(ip=host_ip)

    print('>>> host = ' + str(hostname) + ', ip = ' + str(host_ip) +
          ', @(' + str(lat) + ', ' + str(lng) + ')')

    return {'latitude': lat, 'longitude': lng}
dataset/ETHPy150Open satnet-project/server/services/configuration/ajax/views.py/hostname_geoip/original