



급하게 질문이 있어서 문의 드립니다. (맥입니다.)
4주차 숙제를 진행하는데,
서버와, 몽고디비(homework)를 연결하려고,
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:sparta@cluster0.noht2cc.mongodb.net/Cluster0?retryWrites=true&w=majority',tlsCAFile=ca)
db = client.dbsparta
@app.route('/')
def home():
return render_template('index.html')
@app.route("/homework", methods=["POST"])
def homework_post():
name_receive = request.form["name_give"]
comment_receive = request.form["comment_give"]
doc = {
'name': name_receive,
'comment': comment_receive
}
db.homework.insert_one(doc)
return jsonify({'msg':'응원 완료!'})
기존에 썻던 코드를 활용해서 DB에 입력을 시켰는데, 몽고db에는 homework라는 db가 생성이 안되서, 아무래도 계속해서 에러가 발생하는 것 같습니다. 도대체 무엇이 문제인지 계속 혼자 찾아내려고 노력했는데, 모르겠네요. 답변좀 부탁드립니다. 몽고디비는 리프레쉬랑 로그인은 다시 해보았습니다.
