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

app.py code:

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 code:

<!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>


이렇게 했는데


TemplateNotFound

jinja2.exceptions.TemplateNotFound: index.html


Traceback (most recent call last)
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\app.py", line 2548, in __call__
return self.wsgi_app(environ, start_response)
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\app.py", line 2528, in wsgi_app
response = self.handle_exception(e)
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "C:\sprta\projects\prac\app.py", line 6, in home
return render_template('index.html')
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\templating.py", line 146, in render_template
template = app.jinja_env.get_or_select_template(template_name_or_list)
File "C:\sprta\projects\prac\venv\lib\site-packages\jinja2\environment.py", line 1081, in get_or_select_template
return self.get_template(template_name_or_list, parent, globals)
File "C:\sprta\projects\prac\venv\lib\site-packages\jinja2\environment.py", line 1010, in get_template
return self._load_template(name, globals)
File "C:\sprta\projects\prac\venv\lib\site-packages\jinja2\environment.py", line 969, in _load_template
template = self.loader.load(self, name, self.make_globals(globals))
File "C:\sprta\projects\prac\venv\lib\site-packages\jinja2\loaders.py", line 126, in load
source, filename, uptodate = self.get_source(environment, name)
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\templating.py", line 62, in get_source
return self._get_source_fast(environment, template)
File "C:\sprta\projects\prac\venv\lib\site-packages\flask\templating.py", line 98, in _get_source_fast
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: index.html

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object



이런식으로 http://localhost:5000을 치니 위에 오류가 나네요ㅠㅠ

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