Skip to content

Instantly share code, notes, and snippets.

@LAMike310
Last active December 12, 2016 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LAMike310/772fbff87a4d7840661104bb3f24fbc5 to your computer and use it in GitHub Desktop.
Save LAMike310/772fbff87a4d7840661104bb3f24fbc5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from two1.wallet import Wallet
from two1.bitrequests import BitTransferRequests
# set up bitrequest client for BitTransfer requests
wallet = Wallet()
requests = BitTransferRequests(wallet)
# server address
server_url = 'http://[::1]:5000/'
def getEstimate():
# get the question from the server
response = requests.get(url=server_url+'start')
startAddressText = response.text
ogStart = input(startAddressText)
response = requests.get(url=server_url+'getEndAddress')
startAddressText = response.text
ogEnd = input(startAddressText)
print("Hold on tight, we are searching 20 possible routes for the best price...")
print("")
url = "https://kdszo9c85m.execute-api.us-west-2.amazonaws.com/prod/21-scip"
r = requests.post(url, json={ "originalAddress": ogStart, "targetDestination": ogEnd })
response = r.json()
print("**********************")
if 'errorMessage' not in response:
start_address = response['start_address']
end_address = response['end_address']
discount = response['discount']
price = response['price']
if discount == '0.00':
print('Your in the perfect location for a ride! We did not find any better rates.')
print("")
else:
print("")
print("Here is the best route, you can save $%s" %(discount))
print("Depart from %s" % (start_address))
print("Arrive at %s" % (end_address))
print("Current price for this route is $%s" % (price))
print("")
else:
print("πŸ’© πŸ’© πŸ’© πŸ’© πŸ’© πŸ’© πŸ’©")
print("")
print(response['errorMessage'])
print("")
print("πŸ•΅ πŸ•΅ πŸ•΅ πŸ•΅ πŸ•΅ πŸ•΅ πŸ•΅")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment