
강의 내용대로 index.html에 [GET 요청 확인 Ajax코드] 코드스니펫을 넣고
app.py에 [GET 요청 API코드] 코드스니펫을 넣었습니다.
그외 강의 내용대로 따라해봤는데
오류가 뜬 건 아니지만 강의 내용대로
http://localhost:5000 에서 버튼을 클릭해도 "봄날은 간다"라는 메시지가 콘솔창에 표시되지 않습니다.
아무 반응이 없네요?? 혹시 제가 뭔가를 빠트렸는지 찾아봐도 잘 모르겠어요
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
function hey() {
$.ajax({
type: "GET",
url: "/test?title_give=봄날은간다",
data: {},
success: function (response) {
console.log(response)
}
})
}
</script>
</head>
<body>
<h1>나의 첫 웹페이지</h1>
<button>버튼을 만들자</button>
</body>
</html>
이건 index.html 이고
from flask import Flask, render_template, request, jsonify
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/test', methods=['GET'])
def test_get():
title_receive = request.args.get('title_give')
print(title_receive)
return jsonify({'result':'success', 'msg': '이 요청은 GET!'})
if __name__ == '__main__':
app.run('0.0.0.0',port=5000,debug=True)
이게 제 app.py인데

버튼을 만들자 라는 버튼을 눌러도 아무런 메시지도 콘솔창에 뜨질 않습니다.
