2017-11-08 14:33:05 +00:00
|
|
|
import logging
|
|
|
|
import tornado.web
|
|
|
|
|
2018-04-11 04:48:58 +00:00
|
|
|
from tornado.ioloop import IOLoop
|
|
|
|
from tornado.options import parse_command_line, options
|
|
|
|
from handler import IndexHandler, WsockHandler
|
|
|
|
from settings import get_application_settings
|
2018-03-20 23:38:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parse_command_line()
|
|
|
|
settings = get_application_settings()
|
2017-11-08 14:33:05 +00:00
|
|
|
|
|
|
|
handlers = [
|
|
|
|
(r'/', IndexHandler),
|
|
|
|
(r'/ws', WsockHandler)
|
|
|
|
]
|
|
|
|
|
2018-04-05 05:50:04 +00:00
|
|
|
loop = IOLoop.current()
|
2017-11-08 14:33:05 +00:00
|
|
|
app = tornado.web.Application(handlers, **settings)
|
2018-04-05 05:50:04 +00:00
|
|
|
app._loop = loop
|
2017-11-08 14:33:05 +00:00
|
|
|
app.listen(options.port, options.address)
|
|
|
|
logging.info('Listening on {}:{}'.format(options.address, options.port))
|
2018-04-05 05:50:04 +00:00
|
|
|
loop.start()
|
2017-11-08 14:33:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|