def handle_display_PUT(request):
    content_type = request.getHeader('Content-Type')
    data = request.content.read()
    dic = deserialize(data, content_type)
    display.update(dic, content_type)
    cors(request, methods=['GET', 'PUT'])
    return make_response(display, request)
def handle_weatherstation_PUT(request):
    data = request.content.read()
    content_type = request.getHeader('Content-Type')
    dic = deserialize(data, content_type)
    status = weatherstation.update(dic, content_type)

    return make_response(weatherstation, request=request, status=status)
Exemple #3
0
def handle_window_lock_PUT(request):
    data = request.content.read()
    content_type = request.getHeader('Content-Type')
    dic = deserialize(data, content_type)
    lock.update(dic, content_type)
    cors(request, methods=['GET', 'PUT'])
    return make_response(lock, request)
def handle_waterdispenser_valve_PUT(request):
    data = request.content.read()
    content_type = request.getHeader('Content-Type')
    dic = deserialize(data, content_type)
    status = valve.update(dic, content_type)
    cors(request, methods=['GET', 'PUT', 'OPTIONS'])
    return make_response(valve, request=request, status=status)
def handle_lightbulb_PUT(request):
    data = request.content.read()
    content_type = request.getHeader("Content-Type")
    dic = deserialize(data, content_type)
    status = lightbulb.update(dic, content_type)
    cors(request, methods=["GET", "PUT", "OPTIONS"])
    return make_response(lightbulb, request=request, status=status)
def handle_sensor_PUT(request):
    data = request.content.read()
    content_type = request.getHeader('Content-Type')
    dic = deserialize(data, content_type)
    sensing_device.update(dic, content_type)
    cors(request, methods=['GET', 'PUT'])
    return make_response(sensing_device, request)
def handle_dht22_PUT(request):
    data = request.data
    content_type = request.headers.get("Content-Type")
    dic = deserialize(data, content_type)
    dht.update(dic, content_type)
    cors(request, methods=['GET'])
    return make_response(dht, request)
def handle_window_shutter_PUT(request):
    cors(request, methods=['GET', 'PUT', 'OPTIONS'])
    data = request.content.read()
    content_type = request.getHeader('Content-Type')
    dic = deserialize(data, content_type=content_type)

    task.deferLater(reactor, 0.2, shutter.update, dic, content_type)
    deferred_response = task.deferLater(reactor, 0, make_response, shutter, request)
    return deferred_response
def handle_room_window_PUT(request):
    if xwot_app.resources['window']:
        data = request.content.read()
        content_type = request.getHeader('Content-Type')
        dic = deserialize(data, content_type)
        window.update(dic, content_type)
        _data = window.serialize('application/json')

        accept = request.getHeader('Accept')
        d = treq.put(xwot_app.resources['window'], data=_data, headers={'Content-Type': 'application/json'})
        request.setHeader('Content-Type', accept)
        d.addCallback(treq.content)

        return window.serialize(accept)
    else:
        request.setResponseCode(404)
    return ''
Exemple #10
0
def handle_room_PUT(request):
    data = request.content.read()
    content_type = request.getHeader('Content-Type')
    dic = deserialize(data, content_type)
    room.update(dic, content_type)
    return make_response(room, request)