__init__.py 591 Bytes
Newer Older
1 2 3 4 5 6 7 8 9
from typing import Type

from flask import Flask
from graphannis.cs import CorpusStorageManager

from mcserver import Config
from mcserver.app import init_app_common, init_logging


10
def create_csm_app(cfg: Type[Config] = Config) -> Flask:
11 12 13 14 15 16 17 18
    """Creates a new Flask app that represents a Corpus Storage Manager."""

    Config.CORPUS_STORAGE_MANAGER = CorpusStorageManager(Config.GRAPH_DATABASE_DIR)
    app_csm: Flask = init_app_common(cfg=cfg, is_csm=True)
    from csm.app.api import bp
    app_csm.register_blueprint(bp)
    init_logging(app_csm, Config.LOG_PATH_CSM)
    return app_csm