import base64 import json import requests def base64_api(uname, pwd, img): with open(img, 'rb') as f: base64_data = base64.b64encode(f.read()) b64 = base64_data.decode() data = {"username": uname, "password": pwd, "typeid": 27, "image": b64} result = json.loads(requests.post("http://api.ttshitu.com/imageXYPlus", json=data).text) print(result) if result['success']: return result["data"]["result"], result["data"]["id"] else: return result["message"], result["success"] def error_report(rid): d = {"id": rid} result = json.loads(requests.post("http://api.ttshitu.com/reporterror.json", json=d).text) return result["success"]