Python ddnames scripts

Client-side python scripts, copy-paste and its ready to run Python code presents on GitHub repo as well dns-for-iot-python

Register

import pprint
import requests
#change email and password to yours data
email = "yourname@gmail.com"
password = "yourpassword"
dictToSend = {'email':email,'password': password}
res = requests.post('http://136.244.82.142:8000/register', json=dictToSend)
print ('response from server:',res.status_code,":", res.text)
print("res,json",res.json())
pprint.pprint(res.json())

Login

import pprint
import requests
#change email and password to yours data
email = "yourname@gmail.com"
password = "yourpassword"
pload = {"username":email,"password":password}
response = requests.post('http://136.244.82.142:8000/login', data=pload)
print ('Status:',response.status_code)
pprint.pprint(response.json())

Add domain

import pprint
import requests
#CHANGE TOKEN, EMAIL, APIKEY, DOMAIN,IPADDRESS TO YOUR DATA
token= "your token here"
email = "name@gmail.com"
apikey = "your apikey here"
ipaddress = "3.3.3.3" #your ip here
domain= "your domain here"
pload = {"email":email,"apikey":apikey,"ipaddress":ipaddress,"domain":domain}
headers = {"Authorization": f"Bearer {token}"}
response = requests.post('http://136.244.82.142:8000/add', json=pload,headers = headers)
print ('Status:',response.status_code)
pprint.pprint(response.json())

IP Address Update

import pprint
import requests
#CHANGE TOKEN, EMAIL, APIKEY, DOMAIN,IPADDRESS TO YOUR DATA
#MAKE THIS SCRIPT AS A CRON JOB
ipaddress = get('http://fra.rastem.com.ua/ip.php').text.format() #this will get your current device's IP
token= "yourtokenhere"
email = "name@gmail.com"
apikey = "yourapikey"
domain = "yourdomain.com"
pload = {"email":email,"apikey":apikey,"domain":domain,"ipaddress":ipaddress}
headers = {"Authorization": f"Bearer {token}"}
response = requests.post('http://136.244.82.142:8000/update', json=pload, headers=headers)
print ('Status:',response.status_code)
pprint.pprint(response.json())

Account check

import pprint
import requests
#CHANGE TOKEN, EMAIL, APIKEY TO YOUR DATA
token= "your token here"
email = "name@gmail.com"
apikey = "your apikey here"
pload = {"email":email,"apikey":apikey}
headers = {"Authorization": f"Bearer {token}"}
response = requests.get('http://136.244.82.142:8000/check/', json=pload,headers = headers)
print ('Status:',response.status_code)
pprint.pprint(response.json())

Delete domain from DataBase

import pprint
import requests
#CHANGE TOKEN, EMAIL, APIKEY,DOMAIN_REMOED TO YOUR DATA
token= "your token here"
email = "name@gmail.com"
apikey = "your apikey here"
#DOMAIN YOU WANT TO REMOVE:
domain_removed = "your domain here"
pload = {"email":email,"apikey":apikey,"domain_removed":domain_removed}
headers = {"Authorization": f"Bearer {token}"}
response = requests.delete('http://136.244.82.142:8000/delete/', json=pload,headers = headers)
print ('Status:',response.status_code)
pprint.pprint(response.json())