changeset 134:86345d1d8514

more demo statements for use in examples Ignore-this: e0e940387c56a720293a4727b02397b4
author drewp@bigasterisk.com
date Sun, 13 Oct 2013 00:23:31 -0700
parents 74c1245e7aa0
children 88e7dd767550
files service/environment/environment.py
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/service/environment/environment.py	Fri Oct 11 23:14:02 2013 -0700
+++ b/service/environment/environment.py	Sun Oct 13 00:23:31 2013 -0700
@@ -18,16 +18,16 @@
 ROOM = Namespace("http://projects.bigasterisk.com/room/")
 DEV = Namespace("http://projects.bigasterisk.com/device/")
 
-class Index(PrettyErrorHandler, cyclone.web.RequestHandler):
-    def get(self):
-        self.write('this is envgraph: <a href="graph">rdf</a>')
-        
 class GraphHandler(PrettyErrorHandler, cyclone.web.RequestHandler):
     def get(self):
         g = StateGraph(ROOM.environment)
         now = datetime.datetime.now(tzlocal())
 
         g.add((DEV.environment, ROOM.localHour, Literal(now.hour)))
+        g.add((DEV.environment, ROOM.localTimeToMinute,
+               Literal(now.strftime("%H:%M"))))
+        g.add((DEV.environment, ROOM.localTimeToSecond,
+               Literal(now.strftime("%H:%M:%S"))))
 
         for offset in range(-12, 7):
             d = now.date() + datetime.timedelta(days=offset)
@@ -36,7 +36,8 @@
                        Literal(offset)))
 
         g.add((DEV.calendar, ROOM.twilight,
-               ROOM['withinTwilight'] if isWithinTwilight(now) else ROOM['daytime']))
+               ROOM['withinTwilight'] if isWithinTwilight(now) else
+               ROOM['daytime']))
         
         self.set_header('Content-type', 'application/x-trig')
         self.write(g.asTrig())
@@ -44,7 +45,8 @@
 class Application(cyclone.web.Application):
     def __init__(self):
         handlers = [
-            (r"/", Index),
+            (r"/()", cyclone.web.StaticFileHandler,
+             {"path": ".", "default_filename": "index.html"}),
             (r'/graph', GraphHandler),
         ]
         cyclone.web.Application.__init__(self, handlers)