Пример #1
0
    if not json:
        return jsonify({'message': 'no data received'}), 200

    light = Light.get(id)

    if not light:
        return jsonify({'message': 'Light not found'}), 404

    if json.get('name') is not None:
        light.name = json.get('name')

    if json.get('r') is not None:
        light.r = json.get('r')

    if json.get('g') is not None:
        light.g = json.get('g')

    if json.get('b') is not None:
        light.b = json.get('b')

    light.save()

    return jsonify({'message': 'Light saved'}), 200


if __name__ == '__main__':
    Light.create_table()

    app.run(host='0.0.0.0', port=8000, debug=True)