http: Switch to HTTP method dispatcher for /api

This commit is contained in:
Stein Magnus Jodal 2012-11-09 14:52:46 +01:00
parent 9d2732703d
commit 5458c1271f
2 changed files with 6 additions and 2 deletions

View File

@ -57,6 +57,9 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
'tools.staticdir.index': 'index.html',
'tools.staticdir.dir': static_dir,
},
'/api': {
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
},
'/ws': {
'tools.websocket.on': True,
'tools.websocket.handler_cls': ws.WebSocketHandler,

View File

@ -7,12 +7,13 @@ except ImportError as import_error:
class ApiResource(object):
exposed = True
def __init__(self, core):
self.core = core
@cherrypy.expose
@cherrypy.tools.json_out()
def index(self):
def GET(self):
playback_state = self.core.playback.state.get()
track = self.core.playback.current_track.get()
if track: