
@app.route("/mars", methods=["GET"])
def web_mars_get():
return jsonify({'msg': 'GET 연결 완료!'})
ㅇㅕ기 괄호 맞게 되어 있는데 자꾸 이 문구 뜨고 괄호 넣어도 몽고디비로 옮겨 지지가 않네요'
혹시 몰라서 전체 코드도 올려놓을께요
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
import certifi
ca = certifi.where()
client = MongoClient('mongodb+srv://haroe:NaMQOAaOxZuDcXgt@cluster0.jbeqc4x.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=5001, debug=True)