Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9e306942a7
Fetching contributors…

Cannot retrieve contributors at this time

file 28 lines (23 sloc) 0.9 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
from django.http import HttpResponse

from kaylee import kl

def register_node(request):
    reg_data = kl.register(request.META['REMOTE_ADDR'])
    return json_response(reg_data)

#pylint: disable-msg=W0613
#W0613: Unused argument 'request'
@csrf_exempt
@require_http_methods(["POST"])
def subscribe_node(request, app_name, node_id):
    node_config = kl.subscribe(node_id, app_name)
    return json_response(node_config)

@csrf_exempt
def actions(request, node_id):
    if request.method == 'GET':
        return json_response( kl.get_action(node_id) )
    elif request.method == 'POST':
        next_task = kl.accept_result(node_id, request.raw_post_data)
        return json_response(next_task)

def json_response(s):
    return HttpResponse(s, content_type = 'application/json')
Something went wrong with that request. Please try again.