diff --git a/mopidy/frontends/http/__init__.py b/mopidy/frontends/http/__init__.py index d674e1d0..a23886f8 100644 --- a/mopidy/frontends/http/__init__.py +++ b/mopidy/frontends/http/__init__.py @@ -20,10 +20,9 @@ Frontend which lets you control Mopidy through HTTP and WebSockets. When this frontend is included in :attr:`mopidy.settings.FRONTENDS`, it starts a web server at the port specified by :attr:`mopidy.settings.HTTP_SERVER_PORT`. -This web server exposes both a REST web service at the URL ``/api``, and a -WebSocket at ``/ws``. The REST API gives you access to most Mopidy -functionality, while the WebSocket enables Mopidy to instantly push events to -the client, as they happen. +This web server exposes a WebSocket at ``/ws``. The WebSocket gives you access +to Mopidy's full API and enables Mopidy to instantly push events to the client, +as they happen. The web server can also host any static files, for example the HTML, CSS, JavaScript and images needed by a web based Mopidy client. To host static diff --git a/mopidy/frontends/http/actor.py b/mopidy/frontends/http/actor.py index 66ba9f43..ce48b8b3 100644 --- a/mopidy/frontends/http/actor.py +++ b/mopidy/frontends/http/actor.py @@ -16,7 +16,7 @@ try: except ImportError as import_error: raise exceptions.OptionalDependencyError(import_error) -from . import api, ws +from . import ws logger = logging.getLogger('mopidy.frontends.http') @@ -45,7 +45,6 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener): def _create_app(self): root = RootResource() - root.api = api.ApiResource(self.core) root.ws = ws.WebSocketResource(self.core) if settings.HTTP_SERVER_STATIC_DIR: @@ -60,9 +59,6 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener): 'tools.staticdir.index': 'index.html', 'tools.staticdir.dir': static_dir, }, - b'/api': { - 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), - }, b'/ws': { 'tools.websocket.on': True, 'tools.websocket.handler_cls': ws.WebSocketHandler, diff --git a/mopidy/frontends/http/api.py b/mopidy/frontends/http/api.py deleted file mode 100644 index f5a78f99..00000000 --- a/mopidy/frontends/http/api.py +++ /dev/null @@ -1,95 +0,0 @@ -from __future__ import unicode_literals - -from mopidy import exceptions - -try: - import cherrypy -except ImportError as import_error: - raise exceptions.OptionalDependencyError(import_error) - - -class ApiResource(object): - exposed = True - - def __init__(self, core): - self.core = core - self.player = PlayerResource(core) - self.tracklist = TrackListResource(core) - self.playlists = PlaylistsResource(core) - - @cherrypy.tools.json_out() - def GET(self): - return { - 'resources': { - 'player': { - 'href': '/api/player/', - }, - 'tracklist': { - 'href': '/api/tracklist/', - }, - 'playlists': { - 'href': '/api/playlists/', - }, - } - } - - -class PlayerResource(object): - exposed = True - - def __init__(self, core): - self.core = core - - @cherrypy.tools.json_out() - def GET(self): - properties = { - 'state': self.core.playback.state, - 'currentTrack': self.core.playback.current_track, - 'consume': self.core.playback.consume, - 'random': self.core.playback.random, - 'repeat': self.core.playback.repeat, - 'single': self.core.playback.single, - 'volume': self.core.playback.volume, - 'timePosition': self.core.playback.time_position, - } - for key, value in properties.items(): - properties[key] = value.get() - if properties['currentTrack']: - properties['currentTrack'] = properties['currentTrack'].serialize() - return {'properties': properties} - - -class TrackListResource(object): - exposed = True - - def __init__(self, core): - self.core = core - - @cherrypy.tools.json_out() - def GET(self): - tl_tracks_future = self.core.tracklist.tl_tracks - current_tl_track_future = self.core.playback.current_tl_track - tracks = [] - for tl_track in tl_tracks_future.get(): - track = tl_track.track.serialize() - track['tlid'] = tl_track.tlid - tracks.append(track) - current_tl_track = current_tl_track_future.get() - return { - 'currentTrackTlid': current_tl_track and current_tl_track.tlid, - 'tracks': tracks, - } - - -class PlaylistsResource(object): - exposed = True - - def __init__(self, core): - self.core = core - - @cherrypy.tools.json_out() - def GET(self): - playlists = self.core.playlists.playlists.get() - return { - 'playlists': [p.serialize() for p in playlists], - } diff --git a/mopidy/frontends/http/data/index.html b/mopidy/frontends/http/data/index.html index a426b4d5..74d85dd6 100644 --- a/mopidy/frontends/http/data/index.html +++ b/mopidy/frontends/http/data/index.html @@ -79,14 +79,6 @@ you'll always have the following services available.
-Mopidy makes it's API available for use over HTTP at - /api/. The service tries to be RESTful. It serves and - eats JSON data.
-