Exemplo n.º 1
0
    def setUp(self):
        self.temp_dir = tempfile.mkdtemp()
        self.collection_manager = CollectionManager()
        self.rest_app = RestApp(self.temp_dir,
                                collection_manager=self.collection_manager)

        # disable all but critical errors!
        logging.disable(logging.CRITICAL)
Exemplo n.º 2
0
def make_app(global_conf, **local_conf):
    # setup the logger (copied from AnkiServer.apps.rest_app.make_app())
    from AnkiServer.utils import setup_logging
    setup_logging(local_conf.get('logging.config_file'))

    setup_collection = CollectionInitializer()

    app = RestApp(data_root=local_conf['data_root'],
                  allowed_hosts=local_conf.get('allowed_hosts', '127.0.0.1'),
                  setup_new_collection=setup_collection,
                  hook_pre_execute=setup_collection)

    app.add_handler_group('collection', CollectionHandler())

    return app