Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get current ip adress

$ curl 'https://api.ipify.org?format=json'
{"ip":"178.151.26.217"}
Comment

Get IP ADDRESS

ip addr show |grep -w inet |grep -v 127.0.0.1|awk '{ print $2}'| cut -d "/" -f 1
Comment

get ip address

$ curl 'https://api.ipify.org?format=json'
{"ip":"118.179.172.1"}
Comment

Get IP address

from netifaces import interfaces, ifaddresses, AF_INET
for ifaceName in interfaces():
    addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{'addr':'No IP addr'}] )]
    print('%s: %s' % (ifaceName, ', '.join(addresses)))
    
>>>
  lo: 127.0.0.1
  enp30s0: No IP addr
  wlp31s0: 192.168.1.56
Comment

PREVIOUS NEXT
Code Example
Python :: connect and disconnect event on socketio python 
Python :: drop row pandas column value not a number 
Python :: How to check the number of occurence of each character of a given string in python 
Python :: order_by django queryset order by ordering 
Python :: longest common prefix 
Python :: changes in settings.py for media storage without db 
Python :: numpy insert 
Python :: delete file in django terminal 
Python :: start index from 1 in python 
Python :: flask app run 
Python :: how to normalize scipy cross correlation 
Python :: pandas replace values from another dataframe 
Python :: python reverse range 
Python :: download button image streamlit 
Python :: django url with slug 
Python :: longest palindromic substring using dp 
Python :: .corr python 
Python :: python code variable declaration 
Python :: map numpy array 
Python :: make a tuple 
Python :: TRY 
Python :: how to use djoser signals 
Python :: python loop until condition met 
Python :: Remove an element from a Python list Using pop() method 
Python :: catching exceptions in python 
Python :: how to test that an exception was raise using pytest 
Python :: convert time 
Python :: custom permission class django rest framework 
Python :: scapy python functions 
Python :: read yml file in python 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =