커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4-4강 버튼을 만들자 버튼을 누른 뒤 콘솔창에 확인이 안되요
undefined주차
북마크
김*신
댓글
4
추천
0
조회수
8
조회수
8
답변 완료
<!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 onclick="hey()">버튼을 만들자</button>
</body>
<




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)

"C:\Users\82108\OneDrive\바탕 화면\sparta\projects\prac\venv\Scripts\python.exe" "C:/Users/82108/OneDrive/바탕 화면/sparta/projects/prac/app.py"

 * Serving Flask app 'app' (lazy loading)

 * Environment: production

  WARNING: This is a development server. Do not use it in a production deployment.

  Use a production WSGI server instead.

 * Debug mode: on

 * Running on all addresses (0.0.0.0)

  WARNING: This is a development server. Do not use it in a production deployment.

 * Running on http://127.0.0.1:5000

 * Running on http://192.168.219.103:5000 (Press CTRL+C to quit)

 * Restarting with stat

 * Debugger is active!

 * Debugger PIN: 137-368-106

127.0.0.1 - - [25/Jul/2022 14:05:27] "GET /test?title_give=봄날은간다 HTTP/1.1" 200 -

봄날은간다

봄날은간다

127.0.0.1 - - [25/Jul/2022 14:05:31] "GET /test?title_give=봄날은간다 HTTP/1.1" 200 -

봄날은간다

127.0.0.1 - - [25/Jul/2022 14:05:32] "GET /test?title_give=봄날은간다 HTTP/1.1" 200 -

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