From 9c97c0d7ed0dc50d5c216c6003677b3e0c5c6355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Bokros?= Date: Fri, 17 Nov 2017 15:57:03 +0100 Subject: [PATCH] Add initial version of Tornado app --- app.py | 28 ++++++++++++++++++++++++++++ handlers/__init__.py | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 app.py create mode 100644 handlers/__init__.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..0cc1a15 --- /dev/null +++ b/app.py @@ -0,0 +1,28 @@ +import logging + +import tornado +import zmq +from tornado.web import Application +from tornado.ioloop import IOLoop + +from config import WEB_PORT +from handlers import MainHandler, ZMQWebSocketHandler + +if __name__ == '__main__': + routes = [ + (r'/', MainHandler), + (r'/ws', ZMQWebSocketHandler), + ] + application = Application( + routes, + template_path=r'templates/', + static_path=r'static/', + autoreload=True + ) + application.listen(WEB_PORT) + logging.getLogger().setLevel(logging.DEBUG) + logging.debug('Tornado version: {}'.format(tornado.version)) + logging.debug('ZeroMQ version: {}'.format(zmq.zmq_version())) + logging.debug('PyZMQ version: {}'.format(zmq.pyzmq_version())) + logging.info('Tornado application listening on port {}'.format(WEB_PORT)) + IOLoop.instance().start() diff --git a/handlers/__init__.py b/handlers/__init__.py new file mode 100644 index 0000000..b41aa75 --- /dev/null +++ b/handlers/__init__.py @@ -0,0 +1,2 @@ +from .main_handler import MainHandler +from .zmq_websocket_handler import ZMQWebSocketHandler