Giter VIP home page Giter VIP logo

ip2loc-server's Introduction

IP2LOC

A tiny web server for ipv4 to geo location conversion

System Prerequisites

  • SQLite is available (SQLite is included by default in these systems.)
  • Only Python3 supported, >= 3.6 is preferred.

Quick Start

Installation & Run

pip install --user ip2loc-server
ip2loc

Now you have already started the server. Try

curl localhost:8080/ip2loc?ip=216.58.221.228
# {"ip": "216.58.221.228", "country_code": "NL", "country_name": "Netherlands", "region_name": "Noord-Holland", "city_name": "Amsterdam", "latitude": 52.37403, "longitude": 4.88969}
curl localhost:8080/url2loc?url=www.google.com
# {"ip": "216.58.221.228", "country_code": "NL", "country_name": "Netherlands", "region_name": "Noord-Holland", "city_name": "Amsterdam", "latitude": 52.37403, "longitude": 4.88969}
curl localhost:8080/url2loc?url=https://www.google.com
# {"ip": "216.58.221.228", "country_code": "NL", "country_name": "Netherlands", "region_name": "Noord-Holland", "city_name": "Amsterdam", "latitude": 52.37403, "longitude": 4.88969}

to test the server is working well. Run ip2loc -h for more helps.

Server Port

By default the server listens to port 8080, you could ONLY modify this in the configure file. (Arguments specified listening ports are not supported)

In addition multiple ports could be configured as

# multiple listening port example
PORTS = (8080, 8081, 8082,)

Paths

I deliberately do not list the data, configure and log paths in this README file, for the reason that the default paths are all relative paths which are not easy to be described clearly.

To find these useful path info, run

ip2loc --showpath

Track the Latest Data

All the data used in this project is from https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude.

For the reason that the data on this site are updated monthly, you need track the latest data manually.

  • Download "IPV4CSV" and remember the current version of data IP2LocationSiteSnapshot

  • Run ip2loc --loaddata --dataver="current version" --csv="CSV/DATA/PATH/NAME.CSV" or ip2loc --loaddata --dataver="current version" --zip="ZIP/DATA/PATH/NAME.ZIP"

How This Works

Briefly: Binary search of ordered ip data

See https://lite.ip2location.com/database/ip-country-region-city-latitude-longitude for details of data structure.

Contact Me

[email protected]

ip2loc-server's People

Watchers

Zhenning Lang avatar

ip2loc-server's Issues

Plan of ver 0.1.0

  • Argument specified server port(s) support
  • Argument specified log path support
  • Argument specified no file log option
  • Configure and argument specified database support (Use SQLAlchemy instead of sqlite3)
  • Support convenient 'import' interface

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.