示例#1
0
    def run(self, container: Container):
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        handlers = [
            (r"" + self._path_prefix + "/", MainHandler),
            (r"" + self._path_prefix + "/pipeline/([a-z0-9-]+)/declaration",
             DeclarationHandler),
            (r"" + self._path_prefix + "/pipeline/([a-z0-9-]+)/environment",
             EnvHandler),
            (r"" + self._path_prefix +
             "/pipeline/([a-z0-9-]+)/api/lock/([a-z0-9-_.]+)", LocksHandler),
            (r"" + self._path_prefix +
             "/pipeline/([a-z0-9-]+)/api/execute-other",
             ExecutionFromOtherPipeline),
            (r"" + self._path_prefix + "/pipeline/([a-z0-9-]+)/execute",
             ExecutionHandler),
            (r"" + self._path_prefix + "/lock/list", LocksListHandler)
        ]

        for handler in handlers:
            handler[1].inject_container(container)

        handlers = list(
            map(lambda handler: tornado.web.url(handler[0], handler[1]),
                handlers))

        setup_swagger(handlers)

        srv = tornado.web.Application(handlers)
        srv.listen(self._port, self._address)
        loop.run_forever()
示例#2
0
    def __init__(self, async_database, sync_database, config):
        handlers = [
            tornado.web.url(r"/", ServiceDataHandler),
            tornado.web.url(r"/test/", TestStatusDataHandler),
            tornado.web.url(r"/result/", ResultUpdateHandler),
            tornado.web.url(r"/prioritize/", PrioritizeHandler),
            tornado.web.url(r"/last_update/", LastUpdateHandler),
        ]

        settings = dict(
            template_path=TEMPLATES_DIRECTORY,
            static_path=STATIC_DIRECTORY,
            debug=True,
        )
        self.async_db = async_database
        self.sync_db = sync_database
        setup_swagger(
            handlers,
            swagger_url="/doc",
            description=
            'Project repo at https://github.com/salabs/ChangeEngine',
            api_version='0.0.1',
            title='Epimetheus backend API',
        )
        tornado.web.Application.__init__(self, handlers, **settings)
示例#3
0
    def __init__(self, config, **kwargs):
        settings = self.load_configuration(config)

        if kwargs['port'] != 80:
            settings['url'] = settings['url'] + ":" + str(kwargs['port'])

        urls = url_patterns
        if settings['environment'] != 'prod':
            urls.extend(nonprod_url_patterns)
            setup_swagger(urls)

        Application.__init__(self, urls, **settings)
        self.initialize_baseobjects()
示例#4
0
    def __init__(self):
        settings = {"debug": True}

        setup_swagger(
            self._routes,
            swagger_url="/doc",
            description="",
            api_version="1.0.0",
            title="Journal API",
            contact=dict(name="test",
                         email="*****@*****.**",
                         url="https://www.cluas.me"),
        )
        super(Application, self).__init__(self._routes, **settings)
示例#5
0
    def __init__(self):
        middleware_tuple = get_middleware()

        handlers = [
            tornado.web.url('/assassin/tasks', TasksHandler,
                            {'middleware': middleware_tuple}),
            tornado.web.url('/assassin/task', TaskHandler,
                            {'middleware': middleware_tuple}),
            tornado.web.url('/assassin/sub_tasks', SubTasksHandler,
                            {'middleware': middleware_tuple})
        ]
        setup_swagger(handlers,
                      description='Assassin API Definition',
                      title='Assassin API')
        super(Application, self).__init__(handlers)
    def __init__(self):
        settings = {'debug': True}

        setup_swagger(self._routes,
                      swagger_url='/doc',
                      api_base_url='/',
                      description='',
                      api_version='1.0.0',
                      title='Journal API',
                      contact='name@domain',
                      schemes=['https'],
                      security_definitions={
                          'ApiKeyAuth': {
                              'type': 'apiKey',
                              'in': 'header',
                              'name': 'X-API-Key'
                          }
                      })
        super(Application, self).__init__(self._routes, **settings)
示例#7
0
def make_app(cookie_secret, debug):
    base_routing = BaseRoutingHandler()
    mongo = MongodbHandler()

    settings = dict(
        login_url='/login',
        cookie_secret=cookie_secret,
        log_function=log_function,
        debug=debug,
        mongo=mongo,
    )
    _handlers = base_routing.interface_map_list

    setup_swagger(_handlers, title='quota-pusher')
    app = Application(
        handlers=_handlers, **settings)

    app.db = MysqlPool().get_manager()
    app.redis = asyncio.get_event_loop().run_until_complete(RedisPool.create()).get_conn()
    app.mq = MqBase()
    return app
    def __init__(self):
        settings = {"debug": True}

        setup_swagger(
            self._routes,
            swagger_url="/doc",
            api_base_url="/",
            description="",
            api_version="1.0.0",
            title="Journal API",
            contact="name@domain",
            schemes=["https"],
            security_definitions={
                "ApiKeyAuth": {
                    "type": "apiKey",
                    "in": "header",
                    "name": "X-API-Key"
                }
            },
        )
        super(Application, self).__init__(self._routes, **settings)
示例#9
0
    def __init__(self, cfg: DictConfig):
        data = OmegaConf.to_container(cfg)
        caches = self._setup_cache(cfg, "movies")
        _routes = [
            tornado.web.url(r"/api/help", HelperHandler),
            tornado.web.url(r"/api/movies", MoviesHandler,
                            dict(caches=caches)),
            tornado.web.url(r"/api/movies/(.*)", MovieHandler,
                            dict(caches=caches)),
            # tornado.web.url (r"/api/repository/(.*)", RepositoryHandler, dict(repos=data["repositories"])),
            # tornado.web.url (r"/api/credentials", CredentialsHandler),
            # tornado.web.url (r"/api/containers", ContainersHandler),
            # tornado.web.url (r"/api/container/(.*)", ContainerHandler),
            tornado.web.url(
                r"/(.*)", tornado.web.StaticFileHandler, {
                    "path": os.path.join(os.path.dirname(__file__),
                                         "client_files"),
                    "default_filename": "index.html"
                }),
        ]

        setup_swagger(_routes,
                      swagger_url="/doc",
                      api_base_url="/",
                      description="Cmdbweather",
                      api_version="1.0.1",
                      title="omdbweather Service",
                      contact="*****@*****.**",
                      schemes=["http"])
        self._config = cfg
        global_settings = {
            "debug": cfg.debug,
            "static_path": os.path.join(os.path.dirname(__file__),
                                        "client_files"),
        }
        super().__init__(_routes,
                         transforms=[ServerHeaderTransform],
                         **global_settings)
def make_app(args, logger):

    redis_client = redis.Redis(host=args.redis_host, port=args.redis_port, db=0)

    # index = _load_knowledge_index(args.knowledge_index_path)
    # ranker_retriever = TfIdfRankerRetriever(index, new_index=True)

    ranker_retriever = ElasticRankerRetriever(args.elastic_host, args.elastic_port, args.elastic_alias)
    model, tokenizer = _load_model(args)

    routes = [
        tornado.web.url(r"/", CruzControlHandler, dict(args=args,
                                        redis_client=redis_client,
                                        logger=logger,
                                        ranker_retriever=ranker_retriever,
                                        model=model,
                                        tokenizer=tokenizer,
                                        special_tokens=SPECIAL_TOKENS))
    ]

    setup_swagger(routes)

    return tornado.web.Application(routes)
示例#11
0
 def __init__(self):
     setup_swagger(
         self.routes,
         swagger_url=SWAGGER_URL,
     )
     super(Application, self).__init__(self.routes)
示例#12
0
    def __init__(self):
        settings = {'debug': True}

        setup_swagger(self._routes)
        super(Application, self).__init__(self._routes, **settings)
示例#13
0
 def __init__(self):
     setup_swagger(self._routes)
     super(Application, self).__init__(self._routes)
示例#14
0
 def __init__(self, db):
     self.db = db
     setup_swagger(handlers)
     super(Application, self).__init__(handlers, **appsettings)
示例#15
0
    def __init__(self):
        settings = {"debug": True}
        from tornado_swagger.setup import setup_swagger

        setup_swagger(self._routes)
        super(Application, self).__init__(self._routes, **settings)