Mercurial > code > home > repos > environment
comparison rdfdoc.py @ 0:3c1bc3bc5a6c
pull out of homeauto/ project, and add skaffold/pipenv
author | drewp@bigasterisk.com |
---|---|
date | Thu, 31 Mar 2022 22:03:43 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3c1bc3bc5a6c |
---|---|
1 # to be shared somewhere | |
2 import json, cyclone.web | |
3 from cycloneerr import PrettyErrorHandler | |
4 from rdflib import Graph, RDFS, URIRef | |
5 | |
6 graph = Graph() | |
7 graph.parse("docs.n3", format="n3") | |
8 | |
9 # maybe the web page could just query sesame over http and we drop this server | |
10 class Doc(PrettyErrorHandler, cyclone.web.RequestHandler): | |
11 def get(self): | |
12 uri = URIRef(self.get_argument('uri')) | |
13 | |
14 ret = {} | |
15 comment = graph.value(uri, RDFS.comment) | |
16 if comment is not None: | |
17 ret['comment'] = comment | |
18 | |
19 self.set_header("Content-type", "application/json") | |
20 self.write(json.dumps(ret)) |