0
|
1 """
|
|
2 see how a browser talks to this PatchableGraph
|
|
3 """
|
|
4
|
|
5 from rdflib import Namespace, Literal, ConjunctiveGraph, URIRef, RDF
|
|
6 from twisted.internet import reactor
|
|
7 import cyclone.web
|
|
8
|
|
9 from standardservice.logsetup import log, verboseLogging
|
|
10 from patchablegraph import PatchableGraph, CycloneGraphEventsHandler, CycloneGraphHandler
|
|
11
|
|
12 verboseLogging(True)
|
|
13
|
|
14 graph = PatchableGraph()
|
|
15 g = ConjunctiveGraph()
|
|
16 g.add((URIRef('http://example.com/s'),
|
|
17 URIRef('http://example.com/p'),
|
|
18 URIRef('http://example.com/o'),
|
|
19 URIRef('http://example.com/g')))
|
|
20 graph.setToGraph(g)
|
|
21
|
|
22 class Application(cyclone.web.Application):
|
|
23 def __init__(self):
|
|
24 handlers = [
|
|
25 (r'/graph', CycloneGraphHandler, {'masterGraph': graph}),
|
|
26 (r'/graph/events', CycloneGraphEventsHandler,
|
|
27 {'masterGraph': graph}),
|
|
28 ]
|
|
29 cyclone.web.Application.__init__(self, handlers)
|
|
30
|
|
31
|
|
32 reactor.listenTCP(8021, Application())
|
|
33 reactor.run()
|