Mercurial > code > home > repos > homeauto
comparison lib/patchablegraph/patchablegraph.py @ 1504:d8eba5a51c1f
try a text/plain response if we think it's a browser asking for the graph
Ignore-this: 3ab9e0c28cd46aff6d93e818a8a5fbbd
darcs-hash:43107cfc2041fb2a1652265c072aa35c945e129f
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 03 Feb 2020 00:50:53 -0800 |
parents | 43791ec0beb2 |
children | 3cdf76755812 |
comparison
equal
deleted
inserted
replaced
1503:040e5c578fc1 | 1504:d8eba5a51c1f |
---|---|
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): |