Ejemplo n.º 1
0
 def get(self):
     customerID = self.get_cookie("digitATM")
     if customerID is not None:
         balance = RequestManager.getBalance(customerID)
     else:
         self.write("An error occurred when attempting to get the hash value for this customer.".format(customerID))
         return
     if balance is not None:
         self.write("<span style=\"text-align:center\">Customer ID: {0}<br>Balance: {1}<br>Return to <a href=\"/menu\"> the menu</a>.</span>".format(customerID, balance))
         return
     self.write("Customer ID {0} and its corresponding hash exist. However, the balance for this customer could not be determined.".format(customerID))         
Ejemplo n.º 2
0
 def post(self):
     customerID = self.get_argument("customerID", "")
     jsondata = None
     with open("accounts.json", "r") as jsonfile:
         jsondata = json.load(jsonfile)
     customerHash = None
     if jsondata is not None and customerID in jsondata:
         customerHash = jsondata[customerID]
     else:
         self.write("Customer ID {0} is not a valid customer ID.".format(customerID))
         return
     if customerHash is not None:
         balance = RequestManager.getBalance(customerHash)
     else:
         self.write("Although customer ID {0} exists, an error occurred when attempting to get the hash value for customer ID {0}.".format(customerID))
         return
     if balance is not None:
         self.write("Customer ID: {0}\nBalance: {1}".format(customerID, balance))
         return
     self.write("Customer ID {0} and its corresponding hash exist. However, the balance for this customer could not be determined.".format(customerID))