diff --git a/gift.py b/gift.py
index 1bd81c7..769afda 100644
--- a/gift.py
+++ b/gift.py
@@ -116,4 +116,14 @@ def gift(name,email,referer, ip):
return "Error sending gift:
" + send_name.text
- return True
\ No newline at end of file
+ return True
+
+def balance():
+ headers = {"Accept": "application/json", "Content-Type": "application/json"}
+ user_info = requests.get(nb_endpoint + "/api/user",headers=headers, cookies=cookies)
+ if user_info.status_code != 200:
+ return "Error getting user info:
" + user_info.text
+ user_info = user_info.json()
+ hns_balance = user_info['hns_balance']
+ hns_balance = int(hns_balance)/1000000
+ return hns_balance
diff --git a/main.py b/main.py
index dbd827c..e562c6b 100644
--- a/main.py
+++ b/main.py
@@ -76,11 +76,11 @@ def stats():
# Loop through gifts
referals = {}
- for gift in gifts:
- if gift['referer'] not in referals:
- referals[gift['referer']] = 1
+ for gift_item in gifts:
+ if gift_item['referer'] not in referals:
+ referals[gift_item['referer']] = 1
else:
- referals[gift['referer']] += 1
+ referals[gift_item['referer']] += 1
statsHTML = 'Total gifts: ' + str(len(gifts)) + '
'
statsHTML += 'Referals:
'
@@ -88,7 +88,7 @@ def stats():
statsHTML += referal + ': ' + str(referals[referal]) + '
'
-
+ statsHTML += '
Remaining HNS: ' + str(gift.balance()) + '
'
return render_template('stats.html',address=address,stats=statsHTML)