
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
제가 post 기능을 만들다가 비밀번호 기능을 설정했는데,
비밀번호까지 같이 몽고디비에 나와서 이것을 가리는 방법을 챗gpt에 문의하여
아래와 같이 작성했습니다.
근데 get 기능이 처음에는 됐다가 비번 가리기 코드를 작성한 후에는 적용되지 않아서 어떻게 해야 할지 고민입니다.
그러려면 다음 코드를 먼저 이해해야 할 것 같은데
이 코드가 뭔지 먼저 설명해주실 수 있으실까요?
all_comment = list(db.enter.find({},{'_id':False}))
app.py(post 기능)
@app.route("/guestbook", methods=["POST"])
def guestbook_post():
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
}
doc["password"] = bcrypt.hashpw(doc["password"].encode('UTF-8'), bcrypt.gensalt())
masked_doc = doc.copy()
masked_doc["password"] = "********"
db.enter.insert_one(doc)
return jsonify({'msg': '저장 완료!'})
