-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNEMBEX.py
108 lines (92 loc) · 3.38 KB
/
NEMBEX.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
'''
Distributed under the MIT License, see accompanying file LICENSE.txt
'''
import tornado.web
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.locale
import os.path
from ConfigParser import SafeConfigParser
from tornado.options import define, options
#api
from handlers.ApiHandler import BlockAfterHandler
from handlers.ApiHandler import LastBlockHandler
from handlers.ApiHandler import AccountHandler
from handlers.ApiHandler import TransfersHandler
from handlers.ApiHandler import FromToBlocksHandler
from handlers.ApiHandler import SearchBlockByHashHandler
from handlers.ApiHandler import SearchTxByHashHandler
from handlers.ApiHandler import SearchHandler
from handlers.ApiHandler import FromToTxHandler
from handlers.ApiHandler import BlockChartHandler
from handlers.ApiHandler import BlockChartHandlerCustom
from handlers.ApiHandler import HarvesterStatsHandler
from handlers.ApiHandler import CheckNis
#sockets
from handlers.SocketHandler import LatestBlockSocket
from handlers.SocketHandler import LatestTxSocket
parser = SafeConfigParser()
parser.read("settings.INI")
define("port", default=parser.get("blockexplorer", "port"), help="run on the given port", type=int)
if __name__ == '__main__':
tornado.options.parse_command_line()
settings = {
"template_path": os.path.join(os.path.dirname(__file__), "templates"),
"static_path" : os.path.join(os.path.dirname(__file__), 'static'),
"cookie_secret": "doEx8QhSQv+CUoZjKDevtL/5VODeEkUFgbWyv7PO0O4", #define your own here !
"xsrf_cookies": True,
"debug": False,
"gzip":True,
'pycket': {
'engine': 'redis',
'storage': {
'host': 'localhost',
'port': 6379,
'db_sessions': 10,
'db_notifications': 11,
'max_connections': 2 ** 31,
},
},
}
#define the url endpoints
app = tornado.web.Application(
[
#main page stuff
#(r'/', FromToBlocksHandlerTemp),
#(r'/blocks', FromToBlocksHandlerTemp),
#apis
#blocks
(r'/api/block-after', BlockAfterHandler),
(r'/api/last-block', LastBlockHandler),
(r'/api/blocks', FromToBlocksHandler),
#account
(r'/api/account', AccountHandler),
(r'/api/transfers', TransfersHandler),
#txs
(r'/api/txs', FromToTxHandler),
#search
(r'/api/tx', SearchTxByHashHandler),
(r'/api/block', SearchBlockByHashHandler),
(r'/api/search', SearchHandler),
#stats
(r'/api/stats/blocktimes', BlockChartHandler),
(r'/api/stats/v2/blocktimes', BlockChartHandlerCustom),
(r'/api/stats/harvesters', HarvesterStatsHandler),
#sockets
#blocks
(r'/socket/last-block', LatestBlockSocket),
#txs
(r'/socket/last-tx', LatestTxSocket),
#extras
(r'/api/extras/checknis', CheckNis),
],
**settings
)
#load translations
translationsPath = os.path.join(os.path.dirname(__file__), "locale")
tornado.locale.load_translations(translationsPath)
server = tornado.httpserver.HTTPServer(app, xheaders=True)
server.bind(options.port, '127.0.0.1')
server.start()
tornado.ioloop.IOLoop.instance().start()