
localhost:5000과 연결이 안됩니다..

작성한 코드 및 에러 메세지
<app,py 부분>
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
client = MongoClient('mongodb+srv://test:sparta@cluster0.98rz0ep.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)
---------------------------------------------------------------------------------------------------------------------------------------------------
<index.html 부분>
<script>
$(document).ready(function () {
show_order();
});
function show_order() {
$.ajax({
type: 'GET',
url: '/mars',
data: {},
success: function (response) {
alert(response['msg'])
}
});
}
function save_order() {
let name =$('#name').val()
let address =$('#address').val()
let size =$('#size').val()
$.ajax({
type: 'POST',
url: '/mars',
data: {name_give:'name', address_give:'address', size_give:'size'},
success: function (response) {
alert(response['msg'])
window.location.reload()
}
});
}
