|
|
@@ -536,6 +536,14 @@ class Server(object): |
|
|
|
else: |
|
|
|
cherrypy.server.shutdown_timeout = 5 |
|
|
|
|
|
|
|
def get_application(self): |
|
|
|
"""Return a WSGI application object""" |
|
|
|
def app(environ, start_response): |
|
|
|
if environ['wsgi.multiprocess']: |
|
|
|
raise Exception("can't function in a multi-process environment") |
|
|
|
return cherrypy.tree(environ, start_response) |
|
|
|
return app |
|
|
|
|
|
|
|
def json_error_page(self, status, message, traceback, version): |
|
|
|
"""Return a custom error page in JSON so the client can parse it""" |
|
|
|
errordata = { "status" : status, |
|
|
@@ -602,3 +610,10 @@ class Server(object): |
|
|
|
|
|
|
|
def stop(self): |
|
|
|
cherrypy.engine.exit() |
|
|
|
|
|
|
|
def wsgi_application(dbpath): |
|
|
|
"""Return a WSGI application object with a database at the |
|
|
|
specified path.""" |
|
|
|
db = nilmdb.utils.serializer_proxy(nilmdb.server.NilmDB)(dbpath) |
|
|
|
server = nilmdb.server.Server(db, embedded = True) |
|
|
|
return server.get_application() |