added sql stuff
This commit is contained in:
24
Freitag/ext_ip.py
Normal file
24
Freitag/ext_ip.py
Normal file
@@ -0,0 +1,24 @@
|
||||
#! /usr/bin/env python3
|
||||
import requests
|
||||
#import json
|
||||
#localdata = json.loads(json_string) # erzeugt Python-Datemstruktur
|
||||
#jsonstring = json.dumps(data) # erzeugt eni Json-String der Daten
|
||||
#http://ip.jsontest.com
|
||||
#https://luonnotar.infodrom.org/json
|
||||
def get_external_ip():
|
||||
url = 'https://luonnotar.infodrom.org/json'
|
||||
response = requests.get(url)
|
||||
if response.status_code != 200:
|
||||
raise Exception("HTTP Status is " + str(response.status_code))
|
||||
#text = response.content.decode()
|
||||
#print("Content-type der Antwort:", response.headers['Content-Type'])
|
||||
data = response.json()
|
||||
if 'application/json' not in response.headers['Content-Type']:
|
||||
raise Exception ("Content-Type is not application/json")
|
||||
ip = data['ip']['remote']
|
||||
return ip
|
||||
|
||||
|
||||
|
||||
ip = get_external_ip()
|
||||
print("Aktuelle externe IP-Addresse: ", ip)
|
||||
Reference in New Issue
Block a user