Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If by clever flask-redis, and very little js/jquery
code Dig in that direction. In principle, you can also sql
@app.route('/comment/<int:id>/like', methods=["POST"])
@login_required
def comment_like(id):
comment = Comment.query.get_or_404(id)
comment.like += 1
db.session.add(comment)
db.session.commit()
return jsonify({'likes': comment.like})
$('.like-button').onclick(
...
//Post запрос по url, из data-id
$.ajax({
type: 'POST',
url: "/comment/"+data-id+"/like",
data: data
});
// если удался меняем innerhtml
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question