Figure 7-2. Python Sample with HTTP Get Request that Invokes the REST API
#!/usr/bin/python
import httplib
conn = httplib.HTTPConnection("10.42.51.5")
# Send HTTP GET request
conn.request("GET","/cgi-bin/F10Ping?IpAddress=10.42.0.13")
# Get response data
response = conn.getresponse()
# Display response texts on success or display status
if(response.status == 200):
# Handle response data
data = response.read()
print data
else :
# Handle error
print "Operation failed",response.status,response.reason
conn.close()