
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
ca = certifi.where()
client = MongoClient('mongodb+srv://test:sparta@cluster0.ssg19m6.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)
* Detected change in 'C:\\Users\\joon\\Desktop\\sparta\\projects\\mars\\app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 221-171-088
* Detected change in 'C:\\Users\\joon\\Desktop\\sparta\\projects\\mars\\app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 221-171-088
* Detected change in 'C:\\Users\\joon\\Desktop\\sparta\\projects\\mars\\app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 221-171-088
* Detected change in 'C:\\Users\\joon\\Desktop\\sparta\\projects\\mars\\app.py', reloading
* Restarting with stat
Traceback (most recent call last):
File "C:\Users\joon\Desktop\sparta\projects\mars\app.py", line 6, in <module>
ca = certifi.where()
NameError: name 'certifi' is not defined
종료 코드 1(으)로 완료된 프로세스
제가 3주차 데이터베이스 할때 계속 오류가 나서 이번에는 미리 certifi깔고 시작했는데 오류라고 떠서요..
빼야하나요?
