As we have created the web framework and hosted it on a server, let's see some examples on how to call the APIs using different methods. We would see examples on calling the encode and decode APIs.
Here is the Python code:
import requests
import urllib
endpoint="endpoint ip address"
def getencode(query):
url="http://"+endpoint+"/encode"
payload ='{"encode":"'+query+'"}'
r = requests.post(url = url, data=payload)
output=r.json()
for value in output.values():
encodedvalue=value
return encodedvalue
def getdecode(encodedstring):
url="http://"+endpoint+"/decode"
payload ='{"decode":"'+encodedstring+'"}'
r = requests.post(url = url, data=payload)
output...