move 2 more apis

This commit is contained in:
Tim Bentley 2016-06-19 07:58:15 +01:00
parent 36885263bb
commit 9e62366d2b
3 changed files with 38 additions and 3 deletions

View File

@ -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)

View File

@ -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)/(.*)$')

View File

@ -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