mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 23:21:21 +00:00
Add initial version of Tornado app
This commit is contained in:
parent
5609fde996
commit
9c97c0d7ed
28
app.py
Normal file
28
app.py
Normal file
@ -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()
|
2
handlers/__init__.py
Normal file
2
handlers/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
from .main_handler import MainHandler
|
||||||
|
from .zmq_websocket_handler import ZMQWebSocketHandler
|
Loading…
Reference in New Issue
Block a user