-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
33 lines (26 loc) · 843 Bytes
/
main.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
#import tornado.ioloop
import asyncio
import tornado.web
import tornado.websocket
from tornado.platform.asyncio import AsyncIOMainLoop
from configs.default import *
from handlers.index_handler import IndexHandler
from handlers.websocket_handler import WebSocketHandler
from huffman_core_wrapper.huffman_encoding_core import *
def _main():
# huffman encoding core instance
huff_core_inst = HuffmanEncodingCore()
router = [
(r'/', IndexHandler),
(r'/ws', WebSocketHandler, dict(huff_core=huff_core_inst))
]
AsyncIOMainLoop().install()
ioloop = asyncio.get_event_loop()
app = tornado.web.Application(router)
app.listen(conf_port)
print('huffman encoding core coroutine server start!')
ioloop.run_forever()
# run forever
# tornado.ioloop.IOLoop.current().start()
if __name__ == '__main__':
_main()