Mercurial > code > home > repos > homeauto
changeset 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 | ea7239edfeb1 |
children | 74ad667f8c5b |
files | lib/patchablegraph/patchablegraph.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/patchablegraph/patchablegraph.py Sun Feb 02 14:44:42 2020 -0800 +++ b/lib/patchablegraph/patchablegraph.py Mon Feb 03 00:50:53 2020 -0800 @@ -43,6 +43,15 @@ req.set_header('Content-type', 'application/ld+json') graph.serialize(req, format='json-ld', indent=2) else: + print(f'acceptHeader {acceptHeader}') + if acceptHeader.startswith('text/html'): + # browser; should arrange to pick live view + req.set_header('Content-type', 'text/plain') + lines = graph.serialize(format='nquads') + lines.sort() + req.write(''.join(lines)) + return + req.set_header('Content-type', 'application/x-trig') graph.serialize(req, format='trig')