Example #1
0
def create_todo():
    if not request.json or not 'title' in request.json:
        abort(400)
    todo = {
        'id': todos.all()[-1]['id'] + 1,
        'title': request.json['title'],
        'description': request.json.get('description', ""),
        'done': False
    }
    todos.create(todo)
    return jsonify({'todo': todo}), 201
Example #2
0
def todos_list():
    form = TodoForm()
    error = ""
    if request.method == "POST":
        if form.validate_on_submit():
            todos.create(tuple(form.data.values())[:3])
        return redirect(url_for("todos_list"))
    return render_template("todos.html",
                           form=form,
                           todos=todos.all(),
                           error=error)
Example #3
0
def create_todo():
    if not request.json:
        abort(400)
    todo = {
        'id': todos.all()[-1]['id'] + 1,
        'artist': request.json.get['artist'],
        'year_of_publication': request.json.get['year_of_publication'],
        'CD_name': request.json.get['CD_name'],
        'my_favourite': request.json.get['my_favourite']
    }
    todos.create(todo)
    return jsonify({'todo': todo}), 201
Example #4
0
def todos_list_api_v1():
    artist = request.args.get('artist')
    if artist and len(artist) > 2:
        return jsonify(todos.get_artist(artist))
    return jsonify(todos.all())
Example #5
0
def todos_list_api_v1():
    return jsonify(todos.all())