
서버가 정상작동을하니까 이번에는 오류덩어리가 터져나오네요
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.im2ccmy.mongodb.net/Cluster0?retryWrites=true&w=majority', tlsCAFile=ca)
db = client.dbsparta
@app.route('/')
def home():
return render_template('index.html')
@app.route("/mars", methods=["POST"])
def web_mars_post():
name_receive = request.form['name_give']
address_receive = request.form['address_give']
size_receive = request.form['size_give']
doc = {
'name' : name_receive,
'address' : address_receive,
'size' : size_receive
}
db.mars.insert_one(doc)
return jsonify({'msg': '주문 완료!'})
@app.route("/mars", methods=["GET"])
def web_mars_get():
return jsonify({'msg': 'GET 연결 완료!'})
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
127.0.0.1 - - [25/Oct/2022 09:52:26] "POST /mars HTTP/1.1" 500 -
Traceback (most recent call last):
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/flask/app.py", line 2548, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/flask/app.py", line 2528, in wsgi_app
response = self.handle_exception(e)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/app.py", line 26, in web_mars_post
db.mars.insert_one(doc)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/collection.py", line 621, in insert_one
self._insert_one(
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/collection.py", line 562, in _insert_one
self.__database.client._retryable_write(acknowledged, _insert_command, session)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1475, in _retryable_write
with self._tmp_session(session) as s:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1757, in _tmp_session
s = self._ensure_session(session)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1740, in _ensure_session
return self.__start_session(True, causal_consistency=False)
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/mongo_client.py", line 1685, in __start_session
self._topology._check_implicit_session_support()
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/topology.py", line 538, in _check_implicit_session_support
self._check_session_support()
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/topology.py", line 554, in _check_session_support
self._select_servers_loop(
File "/Users/yuyeongjae/Desktop/sparta/project/marth/venv/lib/python3.8/site-packages/pymongo/topology.py", line 238, in _select_servers_loop
raise ServerSelectionTimeoutError(
pymongo.errors.ServerSelectionTimeoutError: ac-dp9s6rl-shard-00-01.im2ccmy.mongodb.net:27017: connection closed,ac-dp9s6rl-shard-00-02.im2ccmy.mongodb.net:27017: connection closed,ac-dp9s6rl-shard-00-00.im2ccmy.mongodb.net:27017: connection closed, Timeout: 30s, Topology Description: <TopologyDescription id: 6357331c73452ddc73c7490e, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('ac-dp9s6rl-shard-00-00.im2ccmy.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('ac-dp9s6rl-shard-00-00.im2ccmy.mongodb.net:27017: connection closed')>, <ServerDescription ('ac-dp9s6rl-shard-00-01.im2ccmy.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('ac-dp9s6rl-shard-00-01.im2ccmy.mongodb.net:27017: connection closed')>, <ServerDescription ('ac-dp9s6rl-shard-00-02.im2ccmy.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('ac-dp9s6rl-shard-00-02.im2ccmy.mongodb.net:27017: connection closed')>]>
