-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
57 lines (47 loc) · 1.25 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from flask import Flask, jsonify, redirect
import logic
app = Flask(__name__)
@app.route('/')
def hello_world():
return redirect(
'https://github.com/juanjsebgarcia/wallet-balance', code=302)
@app.route('/balance/<wallet>')
def showWalletBalance(wallet):
'''
Returns ETH balance of account
'''
balance = logic.getETHBalance(wallet)
if balance is not None:
return jsonify(balance)
else:
return jsonify(None), 404
@app.route('/balance/<token>/<wallet>')
def showTokenBalance(token, wallet):
'''
Returns token balance for wallet
'''
balance = logic.getTokenBalance(token, wallet)
if balance is not None:
return jsonify(balance)
else:
return jsonify(None), 404
@app.route('/token/<token>')
def showTokenInfo(token):
'''
Returns known token information
'''
info = logic.getTokenInfo(token)
if info is not None:
return jsonify(info)
else:
return jsonify(None), 404
@app.route('/token/<token>/<address>')
def showTokenWallet(token, address):
'''
Returns detailed token balance
'''
info = logic.getTokenBalanceDetail(token, address)
if info is not None:
return jsonify(info)
else:
return jsonify(None), 404