Example #1
0
def get(
    graph,
    types="auto",
    image_patterns=["\.[png|jpg|gif]$"],
    label_properties=LABEL_PROPERTIES,
    hierarchy_properties=[RDFS.subClassOf, RDFS.subPropertyOf],
    add_types_labels=True,
    dbname="RDFLib LOD App",
):

    """
    Get the LOD Flask App setup to serve the given graph
    """

    app = Flask(__name__)

    app.config["graph"] = graph
    app.config["dbname"] = dbname

    app.config["types"] = types

    app.config["js"] = {"endpoint": "static", "filename": "lod.js"}
    app.config["jssetup"] = "lodsetup()"

    app.config["label_properties"] = label_properties
    app.config["hierarchy_properties"] = hierarchy_properties
    app.config["add_types_labels"] = add_types_labels

    app.register_blueprint(endpoint)
    app.register_blueprint(lod)

    app.add_url_rule("/", "index", index)

    # make sure we get one session per app
    app.config["SESSION_COOKIE_NAME"] = "SESSION_" + re.sub("[^a-zA-Z0-9_]", "_", str(graph.identifier))
    app.secret_key = "veryverysecret" + str(graph.identifier)

    return app