def create_app(config=None, sync_app=None, user_manager=None, collection_manager=None): from flask import Flask logging.basicConfig( level=logging.DEBUG, format="[%(asctime)s]:%(levelname)s:%(name)s:%(message)s") if config is None: config = load() app = Flask("ankisyncd") app.logger.setLevel(logging.DEBUG) if user_manager is None: user_manager = get_user_manager(config) if collection_manager is None: collection_manager = get_collection_manager(config) if sync_app is None: sync_app = SyncApp(config, user_manager=user_manager, collection_manager=collection_manager) app.register_blueprint(sync.create_blueprint(sync_app=sync_app)) app.register_blueprint( api.create_blueprint(config, user_manager, collection_manager), url_prefix="/api", ) return app
def __init__(self, config, user_manager=None, collection_manager=None): from ankisyncd.thread import get_collection_manager self.data_root = os.path.abspath(config["data_root"]) self.base_url = config["base_url"] self.base_media_url = config["base_media_url"] self.setup_new_collection = None self.prehooks = {} self.posthooks = {} if not user_manager: self.user_manager = get_user_manager(config) else: self.user_manager = user_manager if not collection_manager: self.collection_manager = get_collection_manager(config) else: self.collection_manager = collection_manager self.session_manager = get_session_manager(config) self.full_sync_manager = get_full_sync_manager(config) # make sure the base_url has a trailing slash if not self.base_url.endswith("/"): self.base_url += "/" if not self.base_media_url.endswith("/"): self.base_media_url += "/"
def __init__(self, config): from ankisyncd.thread import get_collection_manager self.data_root = os.path.abspath(config['data_root']) self.base_url = config['base_url'] self.base_media_url = config['base_media_url'] self.setup_new_collection = None self.user_manager = get_user_manager(config) self.session_manager = get_session_manager(config) self.full_sync_manager = get_full_sync_manager(config) self.collection_manager = get_collection_manager(config) # make sure the base_url has a trailing slash if not self.base_url.endswith('/'): self.base_url += '/' if not self.base_media_url.endswith('/'): self.base_media_url += '/'
def __init__(self, config): from ankisyncd.thread import get_collection_manager self.data_root = os.path.abspath(config['data_root']) self.base_url = config['base_url'] self.base_media_url = config['base_media_url'] self.setup_new_collection = None self.prehooks = {} self.posthooks = {} self.user_manager = get_user_manager(config) self.session_manager = get_session_manager(config) self.full_sync_manager = get_full_sync_manager(config) self.collection_manager = get_collection_manager(config) # make sure the base_url has a trailing slash if not self.base_url.endswith('/'): self.base_url += '/' if not self.base_media_url.endswith('/'): self.base_media_url += '/'