
사이트 연결할 수 없다고 나옵니다!
아까 서버랑 html 연결된건 확인했는데,
post 코드 쓰고 나니까 아래처럼 나옵니다!

작성한 파이썬 코드는 아래와 같고
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.j8ppsa9.mongodb.net/?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_recevie,
'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)
에러메세지는 아래와 같습니다.
/Users/dram/Desktop/sparta/projects/mars/venv/bin/python /Users/dram/Desktop/sparta/projects/mars/app.py
Traceback (most recent call last):
File "/Users/dram/Desktop/sparta/projects/mars/app.py", line 5, in <module>
import certifi
ModuleNotFoundError: No module named 'certifi'
종료 코드 1(으)로 완료된 프로세스
certifi 를 못찾겠다고 해서 import certifi 코드도 썼는데, 똑같습니다.
