|
|
@ -20,15 +20,11 @@ class APIrequest: |
|
|
|
async def get( dest: str="", payload: str="" ): |
|
|
|
async def get( dest: str="", payload: str="" ): |
|
|
|
try: |
|
|
|
try: |
|
|
|
apiReq = req.get( genUrl(dest), data = payload ) |
|
|
|
apiReq = req.get( genUrl(dest), data = payload ) |
|
|
|
return apiReq |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except req.exceptions.RequestException as err: |
|
|
|
if( apiReq.status_code != 200 ): # print out the error if the status code is not 200 |
|
|
|
print(err) |
|
|
|
print(apiReq) |
|
|
|
|
|
|
|
print(apiReq.text) |
|
|
|
|
|
|
|
|
|
|
|
# POST Req |
|
|
|
|
|
|
|
async def post( dest: str="", payload: str="" ): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
apiReq = req.post( genUrl(params), data = payload ) |
|
|
|
|
|
|
|
return apiReq |
|
|
|
return apiReq |
|
|
|
|
|
|
|
|
|
|
|
except req.exceptions.RequestException as err: |
|
|
|
except req.exceptions.RequestException as err: |
|
|
@ -38,8 +34,11 @@ class APIrequest: |
|
|
|
async def put( dest: str="", payload: str="" ): |
|
|
|
async def put( dest: str="", payload: str="" ): |
|
|
|
try: |
|
|
|
try: |
|
|
|
apiReq = req.put( genUrl(dest), data = payload ) # send the payload |
|
|
|
apiReq = req.put( genUrl(dest), data = payload ) # send the payload |
|
|
|
print(apiReq) |
|
|
|
|
|
|
|
print(apiReq.text) |
|
|
|
if( apiReq.status_code != 200 ): |
|
|
|
|
|
|
|
print(apiReq) |
|
|
|
|
|
|
|
print(apiReq.text) |
|
|
|
|
|
|
|
|
|
|
|
return apiReq |
|
|
|
return apiReq |
|
|
|
|
|
|
|
|
|
|
|
except req.exceptions.RequestException as err: |
|
|
|
except req.exceptions.RequestException as err: |
|
|
|