@app.route ('/ friend_request /', method = ['GET', 'POST']) def friend_request (friend_id): # проверить, что пользователь вошел в систему, если не "current_user" в сеансе: flash ("Выдолжен войти в систему, чтобы получить доступ к этой странице ") return redirect (url_for (" login "))
# find friends email
friends_email = query_db("select * from users where z_id=?", [friend_id], one=True)["email"]
# send email to friend
sendmail(friends_email, "Friend Request", friendRequestEmailText(session["current_user"], friend_id))
# add pending friend request
insert("friends", False, ["reference", "friend", "accepted"], [session["current_user"], friend_id, 0])
flash("Friend request sent")