diff --git a/docs/conf.py b/docs/conf.py index d02303df..7e626d99 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,6 +37,7 @@ class Mock(object): MOCK_MODULES = [ + 'cherrypy', 'dbus', 'dbus.mainloop', 'dbus.mainloop.glib', @@ -51,6 +52,11 @@ MOCK_MODULES = [ 'pykka.registry', 'pylast', 'serial', + 'ws4py', + 'ws4py.messaging', + 'ws4py.server', + 'ws4py.server.cherrypyserver', + 'ws4py.websocket', ] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock() diff --git a/docs/modules/frontends/http.rst b/docs/modules/frontends/http.rst new file mode 100644 index 00000000..31366bd1 --- /dev/null +++ b/docs/modules/frontends/http.rst @@ -0,0 +1,8 @@ +.. _http-frontend: + +********************************************* +:mod:`mopidy.frontends.http` -- HTTP frontend +********************************************* + +.. automodule:: mopidy.frontends.http + :synopsis: HTTP and WebSockets frontend diff --git a/mopidy/frontends/http/__init__.py b/mopidy/frontends/http/__init__.py index e740677a..ab5c3e22 100644 --- a/mopidy/frontends/http/__init__.py +++ b/mopidy/frontends/http/__init__.py @@ -1,2 +1,36 @@ +""" +Frontend which lets you control Mopidy through HTTP and WebSockets. + +**Dependencies** + +- ``cherrypy`` + +- ``ws4py`` + +**Settings** + +- :attr:`mopidy.settings.HTTP_SERVER_HOSTNAME` + +- :attr:`mopidy.settings.HTTP_SERVER_PORT` + +**Usage** + +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. + +It is also the intention that the frontend should be able to host static files +for any external JavaScript client. This has currently not been implemented. + +**API stability** + +This frontend is currently to be regarded as **experimental**, and we are not +promising to keep any form of backwards compatibility between releases. +""" + # flake8: noqa from .actor import HttpFrontend diff --git a/mopidy/frontends/http/actor.py b/mopidy/frontends/http/actor.py index 57af23d0..c9ae651e 100644 --- a/mopidy/frontends/http/actor.py +++ b/mopidy/frontends/http/actor.py @@ -7,8 +7,8 @@ from mopidy.core import CoreListener try: import cherrypy - from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool from ws4py.messaging import TextMessage + from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool except ImportError as import_error: raise exceptions.OptionalDependencyError(import_error)