added sql stuff

This commit is contained in:
2022-11-25 12:55:49 +01:00
parent aea7c693d6
commit 0c233cdce8
11 changed files with 365 additions and 0 deletions

24
Freitag/ext_ip.py Normal file
View 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)