커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
데이터 삭제
undefined주차
북마크
연*아
댓글
18
추천
0
조회수
69
조회수
69
답변 완료
from flask import Flask, render_template, request, jsonify

app = Flask(__name__)

from pymongo import MongoClient

import certifi

ca = certifi.where()

client = MongoClient('mongodb+srv://test:test@cluster0.u2iw4lb.mongodb.net/Cluster0?retryWrites=true&w=majority', tlsCAFile=ca)
db = client.dbsparta


@app.route('/')
def home():
    return render_template('index.html')


@app.route("/grboy", methods=["POST"])
def homework_post():
    name_receive = request.form['name_list']
    comment_receive = request.form['comment_list']

    doc = {
        'name_list': name_receive,
        'comment_list': comment_receive
    }
    db.grboy.insert_one(doc)

    return jsonify({'msg': '응원 남기기 성공!'})


@app.route("/grboy", methods=["GET"])
def homework_get():
    all_usercomment = list(db.grboy.find({}, {'_id': False}))
    return jsonify({'usercomment': all_usercomment})


if __name__ == '__main__':
    app.run('0.0.0.0', port=5000, debug=True)


db.grboy.delete_one({'test':'test'})  << 데이터 하나만 삭제 하고 싶은데 안되네용 ?? << 마지막 저거 넣고 실행 했는데도 디비에 계속 남아있어요




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴