Exemplo n.º 1
0
def main():
    """Esign DB program main function."""

    handlers = [
        (r'/', IndexHandler),
        (r'/text', TextHandler),
        (r'/back/api/explain', TextHandler),
        (r'/test(?P<path>.*)?', TestHandler),
        (r'/service-worker.js', ServiceWorkerHandler),
    ]

    handlers += [(f'/middle{handler[0]}', handler[1])
                 for handler in HANDLER_LIST]
    # handlers += PAY_URLS

    tornado_app = web.Application(
        handlers=handlers,
        template_path=os.path.join(os.path.dirname(__file__), 'templates'),
        static_path=os.path.join(os.path.dirname(__file__), 'static'),
        cookie_secret='QiNDQXm6ReOfl1VOGhdLoZ0f3ZucyEg6psGNLu1tWZE=',
    )

    tornado_server = httpserver.HTTPServer(
        tornado_app,
        xheaders=True,
    )

    # if options.port == 0:
    #     options.port = config.server.port
    # else:
    #     config.server.port = options.port

    tornado_server.listen(config.server.port)
    print('start listen...')
    sys.stdout.write('\nconfig:\n')
    json.dump(config.traverse(), sys.stdout, indent=4, sort_keys=True)
    sys.stdout.write('\n\n\n')
    sys.stdout.flush()

    ioloop.IOLoop.instance().start()
Exemplo n.º 2
0
def main():
    """Esign DB program main function."""

    handlers = [
        (r'/', IndexHandler),
        (r'/text', TextHandler),
        (r'/back/api/explain', TextHandler),
        (r'/test(?P<path>.*)?', TestHandler),
        (r'/image/(?P<image_id>[a-zA-Z0-9\-]{36})(?P<image_type>.jpg|.png|.gif)',
         ImageHandler),
        (r'/finish', TestFinish),
        (r'/service-worker.js', ServiceWorkerHandler),
    ]

    handlers += [(f'/middle{handler[0]}', handler[1])
                 for handler in HANDLER_LIST]

    tornado_app = web.Application(
        handlers=handlers,
        template_path=os.path.join(os.path.dirname(__file__), 'templates'),
        static_path=os.path.join(os.path.dirname(__file__), 'static'),
        cookie_secret='QiNDQXm6ReOfl1VOGhdLoZ0f3ZucyEg6psGNLu1tWZE=',
        debug=config.debug)

    tornado_server = httpserver.HTTPServer(
        tornado_app,
        xheaders=True,
    )

    tornado_server.listen(config.server.port)
    print('start listen...')
    sys.stdout.write('\nconfig:\n')
    json.dump(config.traverse(), sys.stdout, indent=4, sort_keys=True)
    sys.stdout.write('\n\n\n')
    sys.stdout.flush()

    ioloop.IOLoop.instance().start()