nilmdb/pytables-test/server.py
Jim Paris ef2db81d11 Misc
git-svn-id: https://bucket.mit.edu/svn/nilm/nilmdb@10367 ddd99763-3ecb-0310-9145-efcb8ce7c51f
2012-02-08 18:01:05 +00:00

54 lines
1009 B
Python
Executable File

import sys
import tables
import nilmdb
try:
import cherrypy
cherrypy.tools.json_out
except:
sys.stderr.write("Cherrypy 3.2+ required\n")
sys.exit(1)
class NilmApp:
def __init__(self, db):
self.db = db
class Root(NilmApp):
"""NILM Database"""
server_version = "1.0"
@cherrypy.expose
def index(self):
raise cherrypy.NotFound()
@cherrypy.expose
def favicon_ico(self):
raise cherrypy.NotFound()
@cherrypy.expose
@cherrypy.tools.json_out()
def version(self):
return self.server_version
class Stream(NilmApp):
"""Stream operations"""
@cherrypy.expose
@cherrypy.tools.json_out()
def list(self):
return
cherrypy.config.update({
'server.socket_host': '127.0.0.1',
'server.socket_port': 12380
})
db = nilmdb.nilmdb()
cherrypy.tree.mount(Root(db), "/")
cherrypy.tree.mount(Stream(db), "/stream")
if __name__ == "__main__":
cherrypy.engine.start()
cherrypy.engine.block()