오늘은 합쳤다.
이름 코멘트 비밀번호를 받아서 doc에 넣어 받은 데이터를 지웠다.
@app.route("/homework", methods=["DELETE"])
def guestBook_del():
name_receive = request.form['name_give']
comment_receive = request.form['comment_give']
password_receive = request.form['password_give']
doc = {
'name': name_receive,
'comment': comment_receive,
'password': password_receive
}
db.homework.delete_one(doc)
return jsonify({'msg':'삭제완료!'})
제거 버튼을 누르면 del_guestbook()이 실행
$.ajax({
type: "GET",
url: "/homework",
data: {},
success: function (response){}
})
서버에 요청 코멘트목록을 받아(comments)
비밀번호확인을 위해 promt받아서
let rows = response['comments']
let inputPassword = prompt("message", "비밀번호를 입력");
if (inputPassword === rows[i]['password'])
같으면
i번째 이름 코멘트 비번을 보내서 삭제 요청
$.ajax({
type: "DELETE",
url: "/homework",
data: {'name_give': name, 'comment_give': comment, 'password_give': password},
success: function () {
alert("삭제완료")
}
})

crud중 update를 이런식으로 해보려고 했다.

이름과 패스워드를 받아서 comment를 변경하는 코드를 짜고
클릭버튼 onclick에 업데이트함수를 달아서
이름과 비밀번호를 빼올려고 했다.
comment는 prompt로 입력받고
그런데 너무 오래걸려서 이번 프로젝트에서는 빠지게 되었다.
혼자 넣어보겠다.