December 2018
Intermediate to advanced
226 pages
4h 57m
English
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 requestsimport urllibendpoint="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 encodedvaluedef getdecode(encodedstring): url="http://"+endpoint+"/decode" payload ='{"decode":"'+encodedstring+'"}' r = requests.post(url = url, data=payload) output=r.json() print (output)encodedvalue=getencode("abhishek[:]password")Read now
Unlock full access