"
return html
def cart_total(cert):
html = ""
for item in cert:
quantity = item['quantity']
if int(quantity) <= 0:
continue
path = item['name']
if path in names:
name = names[path]
image = images[path]
price = prices[path]
else:
name = path
image = "tech/image2.jpg"
price = 45
hns = usdToHNS(price, True)
hns = hns * int(quantity)
hns = "{:,}".format(hns)
html += f"
{hns} HNS"
html += f"
{name}
"
html += f"
{quantity} Packs
"
html += "
"
return html
def script(path):
html = f"""
"""
return html
def usdToHNS(usd, returnInt=False):
global exchange
if exchange['timestamp'] < datetime.datetime.now().timestamp() - 3600:
response = requests.get('https://api.coingecko.com/api/v3/simple/price?ids=handshake&vs_currencies=usd')
exchange['rate'] = response.json()['handshake']['usd']
exchange['timestamp'] = datetime.datetime.now().timestamp()
hns = usd / exchange['rate']
hns = int(hns / 5) * 5
if returnInt:
return int(hns)
hns = "{:,}".format(hns)
return hns
def total_usd(cert):
total = 0
for item in cert:
path = item['name']
if path in prices:
total += prices[path] * int(item['quantity'])
else:
total += 45 * int(item['quantity'])
return total
def total_hns(cert, returnInt=False):
total = 0
for item in cert:
path = item['name']
if path in prices:
total += usdToHNS(prices[path],True) * int(item['quantity'])
else:
total += usdToHNS(45,True) * int(item['quantity'])
if returnInt:
return int(total)
total ="{:,}".format(total)
return total