comparison lib/patchablegraph/patchablegraph.py @ 703:83ccc9ba90ea

try a text/plain response if we think it's a browser asking for the graph Ignore-this: 3ab9e0c28cd46aff6d93e818a8a5fbbd
author drewp@bigasterisk.com
date Mon, 03 Feb 2020 00:50:53 -0800
parents 495f573af4f4
children 74ad667f8c5b
comparison
equal deleted inserted replaced
702:ea7239edfeb1 703:83ccc9ba90ea
41 graph.serialize(req, format='nquads') 41 graph.serialize(req, format='nquads')
42 elif acceptHeader == 'application/ld+json': 42 elif acceptHeader == 'application/ld+json':
43 req.set_header('Content-type', 'application/ld+json') 43 req.set_header('Content-type', 'application/ld+json')
44 graph.serialize(req, format='json-ld', indent=2) 44 graph.serialize(req, format='json-ld', indent=2)
45 else: 45 else:
46 print(f'acceptHeader {acceptHeader}')
47 if acceptHeader.startswith('text/html'):
48 # browser; should arrange to pick live view
49 req.set_header('Content-type', 'text/plain')
50 lines = graph.serialize(format='nquads')
51 lines.sort()
52 req.write(''.join(lines))
53 return
54
46 req.set_header('Content-type', 'application/x-trig') 55 req.set_header('Content-type', 'application/x-trig')
47 graph.serialize(req, format='trig') 56 graph.serialize(req, format='trig')
48 57
49 # forked from /my/proj/light9/light9/rdfdb/rdflibpatch.py 58 # forked from /my/proj/light9/light9/rdfdb/rdflibpatch.py
50 def _graphFromQuads2(q): 59 def _graphFromQuads2(q):