本WebAPI支持IP城市定位和域名查IP定位,同时支持命令行查询
蘭雅sRGB 65214549ba Update README.md | 1 year ago | |
---|---|---|
php | 3 years ago | |
templates | 3 years ago | |
Dockerfile | 3 years ago | |
Dockerfile.alpine | 3 years ago | |
README.md | 1 year ago | |
app.py | 3 years ago | |
china_shift.py | 3 years ago | |
china_shift.so | 3 years ago | |
getmd.py | 1 year ago | |
ipinfo.py | 3 years ago | |
ips.py | 3 years ago |
##【Docker 学习 WebAPI 之 IP 城市定位 容器傻瓜部署】 B站视频
git clone https://github.com/hongwenjun/ip.git
pip3 install Flask ipip-ipdb html2text
cd ip
wget https://cdn.jsdelivr.net/npm/qqwry.ipdb/qqwry.ipdb
flask run --host=0.0.0.0
如果要挂载 /app
目录,宿主机先准备好文件
docker run -d -p 80:5000 --restart=always --name ip hongwenjun/ip
# 使用另一个 python3 镜像挂载
docker run -d -p 80:80 -v /root/ip:/app \
--restart=always --name python3 \
hongwenjun/python3 python3 -m app
Pytyhon 使用百度地图API 进行 IP普通定位和地图显示
演示网址: https://www.262235.xyz/ip/maps/
app.py
中请更换你自己的 API
def ip2gdgps(ip):
url = 'http://iploc.market.alicloudapi.com/v3/ip=' + ip
headers = {"Authorization":"APPCODE <<<IP定位APPCODE>>>" ,"Content-Type":"application/json; charset=utf-8" }
try:
r = requests.get(url=url , headers=headers)
data = r.json()
except :
return
# print(data)
if data['code'] != 100:
return (116.39564504, 39.92998578 , data['code']) # 查不到返回 北京 x,y
elif data['message'] == "success":
x = data['result']['lng']
y = data['result']['lat']
return (x, y, data['code'], data)