
index에 버튼을 생성해서 그 버튼을 누르게되면 응원남기기 페이지로 이동하고 싶은데 404 에러를 반환하네요
그래서 제가 리턴값을 index말고 서브페이지도 넣었는데 아예 오류가 나버리네요




[index]
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta property="og:title" content="기리보이 팬명록" />
<meta property="og:description" content="기리보이한테 하고 싶은 말!" />
<meta property="og:image"
<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>
<link rel="icon" type="image/png" sizes="16x16" href="../static/favicon.png">
<title>기리보이 팬명록</title>
<link rel="stylesheet" href="../static/index.css">
<script>
function cloud() {
$.ajax({
type: "GET",
url: "http://spartacodingclub.shop/sparta_api/weather/seoul",
data: {},
success: function (response) {
let temps = response['temp']
let cloud = response['clouds']
$('#temp').append('현재 서울시 기온 : ' + temps + '˚' + `<br>` + '강수 확률 : ' + cloud);
$('#temp').addClass('text-center');
}
});
}
function chrbtn() {
window.open('comment.html');
}
function closebtn() {
$('#mycard').hide();
}
</script>
</head>
<body>
<div class="container">
<div class="page">
<h1>
Giriboy
</h1>
<header>
<ul>
<li><a href="#">about</a></li>
<li><a href="#">palyer</a></li>
<li><a href="#">comment</a></li>
</ul>
</header>
</div>
<div class="mytitle">
<div>
</div>
<div>
<h1>vacant house</h1>
<p>I've been tryna get it straight but it's fucked up</p>
<p>I've been lovin' you since when I woke up</p>
<p>Face it up and promise that you call</p>
<p>Girl, love, won't you please</p>
</div>
<div>
<h1>vacant house</h1>
<p>I've been tryna get it straight but it's fucked up</p>
<p>I've been lovin' you since when I woke up</p>
<p>Face it up and promise that you call</p>
<p>Girl, love, won't you please</p>
</div>
<div>
</div>
</div>
<div class="section1">
<div class="iframe-text">
<h1>
#기리보이 #킬링벌스 #딩고프리스타일
</h1>
<h2>GIRIBOY with DJ SQ</h2>
<!-- <p>기리보이의 킬링벌스를 라이브로!</p> -->
</div>
<div class="iframe-url">
<div></div>
<!-- <iframe width="1440" height="789" src="https://www.youtube.com/embed/ZX3an8BPozs"
title="기리보이의 킬링벌스를 라이브로! I 키보드, 하루종일, 호구, 2000/90, 빈집 I [DF Killing Verse] GIRIBOY with DJ SQ"
frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe> -->
<iframe width=100% height="500" src="https://www.youtube.com/embed/ZX3an8BPozs?autoplay=1&mute=1"
frameborder="0" allow="accelerometer; allow=" autoplay=1"></iframe>
</div>
</div>
<div class="mycheer">
<div class="cheerBT">
<div></div>
<button onclick="window.open('comment.html')">기리보이에게 하고싶은말</button>
</div>
<!-- <div onclick=" closebtn()" type="button">x
</div> -->
</div>
</div>
</div>
</body>
</html>
[commnet]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta property="og:title" content="기리보이 팬명록" />
<meta property="og:description" content="기리보이한테 하고 싶은 말!" />
<meta property="og:image"
<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>
<link rel="icon" type="image/png" sizes="16x16" href="../static/favicon.png">
<title>기리보이 팬명록</title>
<script>
$(document).ready(function () {
show_order();
});
function show_order() {
$.ajax({
type: 'GET',
url: '/grboy',
data: {},
success: function (response) {
let rows = response['usercomment'];
for (let i = 0; i < rows.length; i++) {
let name = rows[i]['name_list']
let comment = rows[i]['comment_list']
console.log(name, comment);
let temp_html = ` <div class="card-body">
<blockquote class="blockquote mb-0">
<p>${name}</p>
<footer class="blockquote-footer">${comment}</footer>
</blockquote>
</div>`
$('#mycomment').append(temp_html);
}
}
});
}
function save_msg() {
let name = $('#exampleFormControlInput1').val();
let comment = $('#exampleFormControlTextarea1').val();
$.ajax({
type: 'POST',
url: '/grboy/dones',
data: { name_list: name, comment_list: comment },
success: function (response) {
console.log(response['msg'])
alert('응원 남기기 성공!')
window.location.reload();
}
});
}
</script>
</head>
<body>
<div id="mycard" class="mysection">
<div>
<label for="exampleFormControlInput1" class="form-label"></label>
<input type="email" class="form-control" id="exampleFormControlInput1" placeholder="닉네임">
</div>
<div>
<label for="exampleFormControlTextarea1" class="form-label"></label>
<textarea class="form-control" id="exampleFormControlTextarea1" placeholder="응원댓글" rows="3"></textarea>
</div>
<button type="button" onclick="save_msg()" class="btn btn-danger">확인</button>
<!--댓글 시작-->
<div id="mycomment">
</div>
<!--댓글 끝-->
</div>
</body>
</html>
[app.py]
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
from pymongo import MongoClient
import certifi
ca = certifi.where()
client = MongoClient('mongodb+srv://test:test@cluster0.u2iw4lb.mongodb.net/Cluster0?retryWrites=true&w=majority', tlsCAFile=ca)
db = client.dbsparta
db.grboy.delete_one({'1':'1'})
@app.route('/')
def home():
return render_template('index.html')
# @app.route('/')
# def sub():
# return render_template('comment.html')
@app.route("/grboy/done", methods=["POST"])
def homework_post():
name_receive = request.form['name_list']
comment_receive = request.form['comment_list']
doc = {
'name_list': name_receive,
'comment_list': comment_receive
}
db.grboy.insert_one(doc)
return jsonify({'msg': '응원 남기기 성공!'})
@app.route("/grboy", methods=["GET"])
def homework_get():
all_usercomment = list(db.grboy.find({}, {'_id': False}))
return jsonify({'usercomment': all_usercomment})
if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
