def graph_response(graph, format):
    '''
    Return a proper flask response for a RDF resource given an expected format.
    '''
    fmt = guess_format(format)
    if not fmt:
        abort(404)
    headers = {
        'Content-Type': RDF_MIME_TYPES[fmt]
    }
    kwargs = {}
    if fmt == 'json-ld':
        kwargs['context'] = context
    if isinstance(graph, RdfResource):
        graph = graph.graph
    return graph.serialize(format=fmt, **kwargs), 200, headers
Return a proper flask response for a RDF resource given an expected format.