커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4-5 백엔드 파일코드를 건드것도 없고 그대로 인 것 같은데 저는 localhost:5000를 치면 사이트에 연결 할 수없음 이 뜹니다.
undefined주차
북마크
이*석
댓글
7
추천
0
조회수
16
조회수
16
답변 완료

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

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


백엔드 파일코드를 건드것도 없고 그대로 인 것 같은데 저는 mypage를 지우고 localhost:5000를 치면 사이트에 연결 할 수없음 이 뜹니다.

localhost에서 연결을 거부했다는데 왜 그런건가요? 벡엔드 코드랑 프론트엔드 코드도 첨부합니다.

백엔드 포스트도 5000이고 관리자실행 상태입니다.


스파르타 즉문즉답





백엔드

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



프론트엔드


<!DOCTYPE html>
<html lang="en">


<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <title>Document</title>


    <script>
        function hey() {
            fetch("/test").then(res => res.json()).then(data => {
                console.log(data)
            })
        }
    </script>
</head>


<body>
    <h1>제목을 입력합니다</h1>
    <button onclick="hey()">나는 버튼!</button>
</body>


</html>
취소
 공유
취소
댓글 0
댓글 알림
나의얼굴