def {{ python.create_blueprint_from_app|base_name }}(app):
    """Create {{ python.package_name }} blueprint."""
    blueprint = app.extensions["{{ python.flask_extension_name }}"].resource.as_blueprint()
    blueprint.record_once(init)
    return blueprint


def init(state):
    """Init app."""
    app = state.app
    ext = app.extensions["{{ python.flask_extension_name }}"]

    # register service
    sregistry = app.extensions["invenio-records-resources"].registry
    sregistry.register(ext.service, service_id="{{ python.flask_extension_name }}")

    # Register indexer
    iregistry = app.extensions["invenio-indexer"].registry
    iregistry.register(ext.service.indexer, indexer_id="{{ python.flask_extension_name }}")
