Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Simple GeoIP Lookup Endpoint

node v10.24.1
version: 1.0.0
endpointsharetweet
const apimon = require("apimon"); exports.endpoint = (request, response) => { response.write("Simple GeoIP Lookup Endpoint powered by Apimon.\r\n\r\n"); const path = require('url').parse(request.url).pathname.substr(1); if(path) { apimon.geoip(path).then(result => { response.write("Country: " + result.country.english_name + " (" + result.country.native_name + ")\r\n"); response.write("Region: " + result.region + "\r\n"); response.write("City: " + result.city.name + "\r\n"); response.write("Zip Code: " + result.zip_code + "\r\n"); response.end("IP address owned by: " + result.as.org); }).catch(response.end); } else { response.end("Please provide an IP address."); } };
Loading…

no comments

    sign in to comment