view service/environment/rdfdoc.py @ 1139:db955e7943af

arduinonode reads config from etcd. use pushConfig.py to inform all nodes Ignore-this: 3155d873bb30ca82b48ace7531a550e5 darcs-hash:0b2be13fbb4dc2571bb1bb8ac97f6a1350f36e77
author drewp <drewp@bigasterisk.com>
date Sat, 03 Mar 2018 17:53:37 -0800
parents 98311a863d7e
children
line wrap: on
line source

# to be shared somewhere
import json, cyclone.web
from cycloneerr import PrettyErrorHandler
from rdflib import Graph, RDFS, URIRef

graph = Graph()
graph.parse("docs.n3", format="n3")

# maybe the web page could just query sesame over http and we drop this server
class Doc(PrettyErrorHandler, cyclone.web.RequestHandler):
    def get(self):
        uri = URIRef(self.get_argument('uri'))

        ret = {}
        comment = graph.value(uri, RDFS.comment)
        if comment is not None:
            ret['comment'] = comment
        
        self.set_header("Content-type", "application/json")
        self.write(json.dumps(ret))