
팬명록 app.py 에서 오류가 납니다. 확인 부탁드립니다 ㅠㅠ
코드
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.e16kghp.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':'응원 완료!'})
@app.route("/homework", methods=["GET"])
def homework_get():
comment_list = list(db.homework.find({}, {'_id': False}))
return jsonify({'homework':comment_list})
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
오류 메시지
/Users/Artcube/Desktop/sparta/projects/homework/venv/bin/python /Users/Artcube/Desktop/sparta/projects/homework/app.py
Traceback (most recent call last):
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/srv_resolver.py", line 89, in _resolve_uri
results = _resolve(
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/srv_resolver.py", line 43, in _resolve
return resolver.resolve(*args, **kwargs)
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/dns/resolver.py", line 1193, in resolve
return get_default_resolver().resolve(qname, rdtype, rdclass, tcp, source,
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/dns/resolver.py", line 1090, in resolve
(answer, done) = resolution.query_result(response, None)
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/dns/resolver.py", line 696, in query_result
raise NoAnswer(response=answer.response)
dns.resolver.NoAnswer: The DNS response does not contain an answer to the question: _mongodb._tcp.cluster0.e16kghp.mongodb.net. IN SRV
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/Artcube/Desktop/sparta/projects/homework/app.py", line 9, in <module>
client = MongoClient('mongodb+srv://test:sparta@cluster0.e16kghp.mongodb.net/Cluster0?retryWrites=true&w=majority',tlsCAFile=ca)
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 726, in __init__
res = uri_parser.parse_uri(
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/uri_parser.py", line 542, in parse_uri
nodes = dns_resolver.get_hosts()
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/srv_resolver.py", line 121, in get_hosts
_, nodes = self._get_srv_response_and_hosts(True)
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/srv_resolver.py", line 101, in _get_srv_response_and_hosts
results = self._resolve_uri(encapsulate_errors)
File "/Users/Artcube/Desktop/sparta/projects/homework/venv/lib/python3.8/site-packages/pymongo/srv_resolver.py", line 97, in _resolve_uri
raise ConfigurationError(str(exc))
pymongo.errors.ConfigurationError: The DNS response does not contain an answer to the question: _mongodb._tcp.cluster0.e16kghp.mongodb.net. IN SRV
종료 코드 1(으)로 완료된 프로세스
