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