커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
request, jsonify 까지 했는데 검사 시 아무것도 뜨질않아요
undefined주차
북마크
정*욱
댓글
5
추천
0
조회수
20
조회수
20
답변 완료


제목 그대로 이 코드로 검사하려고 하는데 hey()가 호출이 안됩니다. 검사시 아무것도 뜨질않아요 잘못 쓴게 있을까요?


그리고 빨간줄이 안없어집니다. 참고로 파이참 껐다켜도 똑같네요



스파르타 즉문즉답



작성한 코드 및 에러 메세지

app.py 코드


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)


index.html


<!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 onclik="hey()">버튼을 만들자</button>
</body>
</html>




취소
 공유
취소
댓글 0
댓글 알림
나의얼굴