-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.py
72 lines (46 loc) · 1.55 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from src.Filter import filters
import web
from src import messages
import json
urls = (
"/","INDEX",
"/btc_recent_big_trans", "BTC_RECENT_BIG_TRANS",
"/eth_recent_big_trans","ETH_RECENT_BIG_TRANS",
"/lib/(.*)","LIB"
)
render = web.template.render("templates/")
app = web.application(urls, globals())
class INDEX(object):
def GET(self):
return render.index()
class ETH_RECENT_BIG_TRANS(object):
def __init__(self):
self.my_filters = filters
self.eth_filter = self.my_filters["ethereum"]()
def GET(self):
data = web.input()
tolerance = data.get("tolerance")
if tolerance: #TODO: Replace with settr
self.eth_filter.track_amnt = int(tolerance)
eth_chain_info = self.eth_filter.getLargeTransactionsFromLatestBlock()
return json.dumps({"response" : eth_chain_info})
class BTC_RECENT_BIG_TRANS(object):
def __init__(self):
self.my_filters = filters
self.btc_filter = self.my_filters["bitcoin"]()
def GET(self):
data = web.input()
tolerance = data.get("tolerance")
if tolerance: #TODO: Replace with settr
self.btc_filter.track_amnt = int(tolerance)
btc_chain_info = self.btc_filter.getLargeTransactionsFromLatestBlock()
return json.dumps({"response" : btc_chain_info})
class LIB(object):
def GET(self,file):
try:
f = open('./scripts/' + file, 'r')
return f.read()
except:
return messages.ERR_404
if __name__ == "__main__":
app.run()