
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.tk2idta.mongodb.net/Cluster0?retryWrites=true&w=majority')
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)
실행시키면 오류가 떠요
C:\Users\82102\Desktop\스파르타\projects\mars\venv\Scripts\python.exe C:/Users/82102/Desktop/스파르타/projects/mars/app.py
File "C:/Users/82102/Desktop/스파르타/projects/mars/app.py", line 19
doc = {
^
IndentationError: unindent does not match any outer indentation level
종료 코드 1(으)로 완료된 프로세스
