1
0
mirror of https://github.com/osmarks/random-stuff synced 2024-12-27 10:30:35 +00:00
random-stuff/spudnet-http.py

14 lines
649 B
Python
Raw Normal View History

2021-04-10 18:31:25 +00:00
import urllib3, json
http = urllib3.PoolManager()
def send(x):
http.request("POST", "https://spudnet.osmarks.net/httponly", body=json.dumps({"mode": "send", "channel": "potatOS", "message": x}), headers={"Content-Type": "application/json"})
while True:
r = http.request("POST", "https://spudnet.osmarks.net/httponly", body=json.dumps({"mode": "recv", "channel": "potatOS", "timeout": 30000}), headers={"Content-Type": "application/json"})
data = json.loads(r.data)
if data["result"] != None:
res = data["result"]["data"]
try:
send(repr(eval(res)))
except Exception as e:
send(repr(e))