커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
api 연결
undefined주차
북마크
조*영
댓글
5
추천
0
조회수
8
조회수
8
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


다시 열어봤는데 갑자기 사이트에 연결할 수 없다고 뜹니다.

네트워크 연결은 잘 되어 있고요.



스파르타 즉문즉답




작성한 코드 및 에러 메세지

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') #title_give 라는 이름으로 뭔가를 받아와서 title_receive 변수에다가 넣었고 title_receive를 찍어줬어. /test라는 창구에서 그것을 받고 있다.
   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=봄날은간다",<!--test창구에 가는데 title_give라는 이름으로 봄날은 간다 라는 데이터를 내가 갖고 갈게-->
                data: {},
                success: function (response) {
                    console.log(response)<!--잘 나오면 너가 주는 데이터를 내가 console에다가 찍어볼게-->
                }
            })
    </script>
</head>
<body>
    <h1>나의 첫 웹페이지!</h1>
    <button oneclick="hey()">버튼을 만들자</button>
</body>
</html>





오류 발생 시, 작성한 코드 전체와 에러 메시지를 첨부해 주세요.

Tip 1) </> 아이콘을 눌러 코드박스를 만들어 보세요.

Tip 2) Ctrl+A(맥의 경우 Command+A) 단축키로 코드를 한 번에 선택할 수 있어요!




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