diff --git a/openlp/core/api/http/endpoint/controller.py b/openlp/core/api/http/endpoint/controller.py index 4bd2f82fe..be24d3acb 100644 --- a/openlp/core/api/http/endpoint/controller.py +++ b/openlp/core/api/http/endpoint/controller.py @@ -23,6 +23,7 @@ import logging import os import urllib.request import urllib.error +import json from openlp.core.api.http.endpoint import Endpoint from openlp.core.api.http import register_endpoint @@ -90,4 +91,20 @@ def controller_text(request): return json_data +@controller_endpoint.route('live/set') +def controller_set(request): + """ + Perform an action on the slide controller. + + :param request: The action to perform. + """ + event = getattr(Registry().get('live_controller'), 'slidecontroller_live_set') + try: + json_data = request.GET.get('data') + data = int(json.loads(json_data)['request']['id']) + event.emit([data]) + except KeyError: + log.error("Endpoint controller/live/set request id not found")s + return {'results': {'success': True}} + register_endpoint(controller_endpoint) diff --git a/openlp/core/api/http/endpoint/core.py b/openlp/core/api/http/endpoint/core.py index 711da6899..2fd0c98f5 100644 --- a/openlp/core/api/http/endpoint/core.py +++ b/openlp/core/api/http/endpoint/core.py @@ -90,10 +90,10 @@ def main_index(request): @blank_endpoint.route('') def static_file_loader(request): """ - Dummy endpoint to trigger endpoint creation + Deliver the page for the / url :param request: """ - pass + return blank_endpoint.render_template('index.mako', **TRANSLATED_STRINGS) # @stage_endpoint.route('(stage)/(.*)$') diff --git a/openlp/core/api/http/endpoint/service.py b/openlp/core/api/http/endpoint/service.py index 366025917..60bb3794f 100644 --- a/openlp/core/api/http/endpoint/service.py +++ b/openlp/core/api/http/endpoint/service.py @@ -20,6 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### import logging +import json from openlp.core.api.http.endpoint import Endpoint from openlp.core.api.http import register_endpoint @@ -32,7 +33,7 @@ service_endpoint = Endpoint('service') @service_endpoint.route('list') -def service_list(request): +def list(request): """ Handles requests for service items in the service manager @@ -40,6 +41,23 @@ def service_list(request): return {'results': {'items': get_service_items()}} +@service_endpoint.route('set') +def service_set(request): + """ + Handles requests for setting service items in the service manager + + :param action: The action to perform. + """ + event = getattr(Registry().get('service_manager'), 'servicemanager_set_item') + try: + json_data = request.GET.get('data') + data = int(json.loads(json_data)['request']['id']) + event.emit(data) + except KeyError: + log.error("Endpoint service/set request id not found") + return {'results': {'success': True}} + + def get_service_items(): """ Read the service item in use and return the data as a json object