automated terminal push
This commit is contained in:
146
RestAPIClient.py
Normal file
146
RestAPIClient.py
Normal file
@@ -0,0 +1,146 @@
|
||||
import requests
|
||||
import json
|
||||
import socket
|
||||
|
||||
## https://www.nylas.com/blog/use-python-requests-module-rest-apis/#how-to-use-python-requests
|
||||
## https://www.abstractapi.com/guides/ip-geolocation/get-ip-address-python
|
||||
|
||||
def ip():
|
||||
|
||||
try:
|
||||
|
||||
public_ip = requests.get('https://api.ipify.org').text
|
||||
|
||||
print(f"Public IP Address: {public_ip}")
|
||||
|
||||
return public_ip
|
||||
|
||||
except requests.RequestException as e:
|
||||
|
||||
print(f"Error retrieving public IP address: {e}")
|
||||
|
||||
return None
|
||||
|
||||
def addDownloadSuccess(url):
|
||||
|
||||
print("enter -> addDownloadSuccess()")
|
||||
|
||||
print("param / url / ",url)
|
||||
|
||||
data = {"url": url, "hostIP": ip(),"ip": ip(),}
|
||||
|
||||
json_data = json.dumps(data)
|
||||
|
||||
print("param / data / ",data)
|
||||
|
||||
print("param / data / ",json_data)
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
|
||||
|
||||
response = requests.post("https://osiris.yankee.embanet.online/channel/monthly/games/success/add", data=json_data, headers=headers)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
def addDownloadFailure(url):
|
||||
|
||||
print("enter -> addDownloadFailure()")
|
||||
|
||||
print("param / url / ",url)
|
||||
|
||||
data = {"url": url, "hostIP": ip(),"ip": ip(),}
|
||||
|
||||
json_data = json.dumps(data)
|
||||
|
||||
print("param / data / ",data)
|
||||
|
||||
print("param / data / ",json_data)
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
|
||||
|
||||
response = requests.post("https://osiris.yankee.embanet.online/channel/monthly/games/failure/add", data=json_data, headers=headers)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#print("params", params)
|
||||
|
||||
#response = requests.post("https://osiris.yankee.embanet.online/channel/monthly/games/success/exists", headers=headers, data=params, params=params)
|
||||
|
||||
#print("response2", response.json())
|
||||
|
||||
|
||||
def searchURLSuccesses(url):
|
||||
|
||||
print("enter -> callGET()")
|
||||
|
||||
print("param / url / ",url)
|
||||
|
||||
params = dict(
|
||||
origin='Chicago,IL',
|
||||
destination='Los+Angeles,CA',
|
||||
waypoints='Joplin,MO|Oklahoma+City,OK',
|
||||
sensor='false',
|
||||
url2=url
|
||||
)
|
||||
|
||||
|
||||
#data = {"name": "Jane Smith", "email": "janesmith@example.com", "url": url }
|
||||
|
||||
data = { "url": url }
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
json_data = json.dumps(data)
|
||||
|
||||
response = requests.post("https://osiris.yankee.embanet.online/channel/monthly/games/success/exists", data=json_data, headers=headers)
|
||||
|
||||
print(response.text)
|
||||
|
||||
return response.text
|
||||
|
||||
def searchURLFailures(url):
|
||||
|
||||
print("enter -> callGET()")
|
||||
|
||||
print("param / url / ",url)
|
||||
|
||||
params = dict(
|
||||
origin='Chicago,IL',
|
||||
destination='Los+Angeles,CA',
|
||||
waypoints='Joplin,MO|Oklahoma+City,OK',
|
||||
sensor='false',
|
||||
url2=url
|
||||
)
|
||||
|
||||
|
||||
#data = {"name": "Jane Smith", "email": "janesmith@example.com", "url": url }
|
||||
|
||||
data = { "url": url }
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
json_data = json.dumps(data)
|
||||
|
||||
response = requests.post("https://osiris.yankee.embanet.online/channel/monthly/games/failure/exists", data=json_data, headers=headers)
|
||||
|
||||
print(response.text)
|
||||
|
||||
return response.text
|
||||
Reference in New Issue
Block a user