2018-02-13 13:35:34 +01:00

28 lines
869 B
Python

import secrets
from tornado.ioloop import IOLoop
from tornado.web import Application
from tao.config import taoenv
from tfw.config import tfwenv
from handlers import SolutionCheckHandler, TestHandler
from tfw.networking.async_solvable_connector import AsyncSolvableConnector
from tfw.config.logs import logging
log = logging.getLogger(__name__)
if __name__ == '__main__':
kwargs = {
'solvable_connector': AsyncSolvableConnector(),
'token': secrets.token_hex(32)
}
routes = [
(r'/{secret}/?'.format(secret=taoenv.SECRET), SolutionCheckHandler, kwargs),
(r'/{secret}/test/?'.format(secret=taoenv.SECRET), TestHandler, kwargs)
]
app = Application(
routes
)
app.listen(tfwenv.CRP_LISTENER_PORT)
log.debug('Controller listening on {}'.format(tfwenv.CRP_LISTENER_PORT))
IOLoop.instance().start()