
sell.html 페이지에서 post를 한다음
index.html 페이지로 get 결과를 요청할 계획입니다.
post가 안되는데, 강의를 다시 봐도....
그대로 응용을 해도 도통 먹히질 않고 에러만 뜹니다..
해결방법이 있을까요?


작성한 코드 및 에러 메세지
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta property="og:description" content="More Creative, Value Creation">
<meta property="og:site_name" content="Be Abstract">
<script defer="defer" src="bundle.js"></script>
<link href="https://fonts.googleapis.com/css2?family=East+Sea+Dokdo&family=Nanum+Brush+Script&display=swap"
rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
<title>Be Abstract | Sell</title>
<style>
.myhead {
font-family: 'East Sea Dokdo', cursive;
font-family: 'Nanum Brush Script', cursive;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.myhead > h1 {
font-size: 100px;
margin: 0px auto 30px auto
}
body {
background-position: center;
background-size: cover;
}
.sell {
width: 500px;
margin: 60px auto 0px auto;
padding-bottom: 60px;
}
.mybtn {
width: 100%;
}
.order > table {
margin: 40px 0;
font-size: 18px;
}
.form-floating {
margin: 10px auto 20px auto;
}
.card-img-top{
margin: 0px auto 20px auto;
}
option {
color: black;
}
</style>
<script>
$(document).ready(function () {
show_order();
});
function save_order() {
let img = $('img').val()
let artist = $('artist').val()
let title = $('title').val()
let cost = $('cost').val()
let comment = $('comment').val()
$.ajax({
type: 'POST',
url: '/sell',
data: {img_give:img, artist_give:artist, title_give:title, cost_give:cost, comment_give:comment},
success: function(response) {
alert(response['msg'])
window.location.reload()
}
});
}
</script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container px-4 px-lg-5">
<a class="navbar-brand" onclick="location.href='/'">Be Abstract</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span
class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0 ms-lg-4">
<li class="nav-item"><a class="nav-link active" aria-current="page" onclick="location.href='/'">Home</a></li>
<li class="nav-item"><a class="nav-link active" aria-current="page" onclick="location.href='/artists'">Artists</a></li>
</ul>
<form class="d-flex">
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
<button class="btn" type="button" onclick="location.href='/sell'">
<i class="sell"></i>
<span class="material-symbols-outlined">
sell
</span>
</button>
<button class="btn" type="button" onclick="location.href='/artist'">
<i class="art_post"></i>
<span class="material-symbols-outlined">
person_add
</span>
</button>
<button class="btn" type="button" onclick="location.href='/login'">
<i class="login me-1"></i>
<span class="material-symbols-outlined">
person
</span>
</button>
<button class="btn" type="button" onclick="location.href='/cart'">
<i class="bi-cart-fill me-1"></i>
<span class="material-symbols-outlined">
shopping_cart
</span>
</button>
</form>
</div>
</div>
</nav>
<div class="mask"></div>
<div class="sell">
<header class="bg-white py-3">
<div class="container px-0 px-lg-0 my-0">
<div class="myhead">
<h1>작품 등록하기</h1>
</div>
</div>
</header>
<div class="sell-info">
<div class="input-group mb-3">
<img class="card-img-top" src="https://dummyimage.com/450x300/dee2e6/6c757d.jpg" alt="..."/>
<input type="file" class="form-control" id="img">
<label class="input-group-text" for="img">Upload</label>
</div>
<div class="input-group mb-3">
<span class="input-group-text">작가명</span>
<input id="artist" class="form-control">
</div>
<div class="input-group mb-3">
<span class="input-group-text">작품 제목</span>
<input id="title" class="form-control">
</div>
<div class="input-group mb-3">
<span class="input-group-text">가격(원)</span>
<input id="cost" type="int" class="form-control">
</div>
<div class="form-floating">
<textarea class="form-control" placeholder="Leave a comment here" id="comment"
style="height: 100px"></textarea>
<label for="comment">작품 설명</label>
</div>
<button onclick="save_order()" type="button" class="btn btn-outline-dark mybtn">작가 인증 요청</button>
</div>
</div>
</body>
</html>
@app.route('/')
def home():
return render_template('index.html')
@app.route('/artist')
def artist():
return render_template('artist.html')
@app.route('/artists')
def artists():
return render_template('artists.html')
@app.route('/cart')
def cart():
return render_template('cart.html')
@app.route('/login')
def login():
return render_template('login.html')
@app.route('/sell')
def sell():
return render_template('sell.html')
@app.route('/sell', methods=["POST"])
def web_sell_post():
img_receive = request.form['img_give']
artist_receive = request.form['artist_give']
title_receive = request.form['title_give']
cost_receive = request.form['cost_give']
comment_receive = request.form['comment_give']
doc = {
'img':img_receive,
'artist':artist_receive,
'title':title_receive,
'cost':cost_receive,
'comment':comment_receive
}
db.abstract.insert_one(doc)
return jsonify({'msg':'등록이 완료되었습니다.'})
@app.route('/sell', methods=["GET"])
def web_sell_get():
sell_list = list(db.sell.find({}, {'_id': False}))
return jsonify({'sells':sell_list})
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
