커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
(4-6) 화성땅 공동구매 뼈대 관련 새로운 에러
undefined주차
북마크
전*경
댓글
2
추천
0
조회수
14
조회수
14
답변 완료

어제 밤에 화성땅 공동구매 뼈대 관련 질문에는 밤사이 튜터님이 답변해주신대로 함수 아래쪽 줄맞추기를 했더니 localhost로 연결은 되었습니다.

그런데 로컬호스트 화면이 이렇네요 ㅜㅜ


스파르타 즉문즉답


app.py 코드는

from flask import Flask, render_template, request, jsonify

app = Flask(__name__)


@app.route('/')
def home():
    return render_template('index.html')


@app.route("/mars", methods=["POST"])
def web_mars_post():
    sample_receive = request.form['sample_give']


    print(sample_receive)
    return jsonify({'msg': 'POST 연결 완료!'})

@app.route("/mars", methods=["GET"])
def web_mars_get():
    return jsonify({'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">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>

<link href="https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&display=swap" rel="stylesheet">

<title>선착순 공동구매</title>

<style>
* {
font-family: 'Gowun Batang', serif;
color: white;
}

body {
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('https://cdn.aitimes.com/news/photo/202010/132592_129694_3139.jpg');
background-position: center;
background-size: cover;
}

h1 {
font-weight: bold;
}

.order {
width: 500px;
margin: 60px auto 0px auto;
padding-bottom: 60px;
}

.mybtn {
width: 100%;
}

.order > table {
margin : 40px 0;
font-size: 18px;
}

option {
color: black;
}
</style>
<script>
$(document).ready(function () {
show_order();
});
function show_order() {
$.ajax({
type: 'GET',
url: '/mars',
data: {},
success: function (response) {
alert(response['msg'])
}
});
}
function save_order() {
$.ajax({
type: 'POST',
url: '/mars',
data: { sample_give:'데이터전송' },
success: function (response) {
alert(response['msg'])
}
});
}
</script>
</head>
<body>
<div class="mask"></div>
<div class="order">
<h1>화성에 땅 사놓기!</h1>
<h3>가격: 평 당 500원</h3>
<p>
화성에 땅을 사둘 수 있다고?<br/>
앞으로 백년 간 오지 않을 기회. 화성에서 즐기는 노후!
</p>
<div class="order-info">
<div class="input-group mb-3">
<span class="input-group-text">이름</span>
<input id="name" type="text" class="form-control">
</div>
<div class="input-group mb-3">
<span class="input-group-text">주소</span>
<input id="address" type="text" class="form-control">
</div>
<div class="input-group mb-3">
<label class="input-group-text" for="size">평수</label>
<select class="form-select" id="size">
<option selected>-- 주문 평수 --</option>
<option value="10평">10평</option>
<option value="20평">20평</option>
<option value="30평">30평</option>
<option value="40평">40평</option>
<option value="50평">50평</option>
</select>
</div>
<button onclick="save_order()" type="button" class="btn btn-warning mybtn">주문하기</button>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">이름</th>
<th scope="col">주소</th>
<th scope="col">평수</th>
</tr>
</thead>
<tbody>
<tr>
<td>홍길동</td>
<td>서울시 용산구</td>
<td>20평</td>
</tr>
<tr>
<td>임꺽정</td>
<td>부산시 동구</td>
<td>10평</td>
</tr>
<tr>
<td>세종대왕</td>
<td>세종시 대왕구</td>
<td>30평</td>
</tr>
</tbody>
</table>
</div>
</body>
</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

'


그리고 파이참 콘솔창엔 이렇게 뜹니다.

C:\Users\cho2\Desktop\sparta\projects\mars\venv\Scripts\python.exe C:/Users/cho2/Desktop/sparta/projects/mars/app.py

 * Serving Flask app 'app'

 * Debug mode: on

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

 * Running on all addresses (0.0.0.0)

 * Running on http://127.0.0.1:5000

 * Running on http://192.168.219.101:5000

Press CTRL+C to quit

 * Restarting with stat

 * Debugger is active!

 * Debugger PIN: 751-333-912

127.0.0.1 - - [10/Aug/2022 08:24:40] "GET / HTTP/1.1" 500 -

Traceback (most recent call last):

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 2548, in __call__

  return self.wsgi_app(environ, start_response)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 2528, in wsgi_app

  response = self.handle_exception(e)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 2525, in wsgi_app

  response = self.full_dispatch_request()

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request

  rv = self.handle_user_exception(e)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request

  rv = self.dispatch_request()

 File "C:\Users\cho2\Desktop\sparta\projects\mars\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:\Users\cho2\Desktop\sparta\projects\mars\app.py", line 8, in home

  return render_template('index.html')

 File "C:\Users\cho2\Desktop\sparta\projects\mars\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:\Users\cho2\Desktop\sparta\projects\mars\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:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\jinja2\environment.py", line 1010, in get_template

  return self._load_template(name, globals)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\jinja2\environment.py", line 969, in _load_template

  template = self.loader.load(self, name, self.make_globals(globals))

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\jinja2\loaders.py", line 126, in load

  source, filename, uptodate = self.get_source(environment, name)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\templating.py", line 62, in get_source

  return self._get_source_fast(environment, template)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\templating.py", line 98, in _get_source_fast

  raise TemplateNotFound(template)

jinja2.exceptions.TemplateNotFound: index.html

127.0.0.1 - - [10/Aug/2022 08:24:40] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:24:40] "GET /favicon.ico HTTP/1.1" 404 -

127.0.0.1 - - [10/Aug/2022 08:24:40] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:24:40] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:24:41] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:26:25] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:29:31] "GET / HTTP/1.1" 500 -

Traceback (most recent call last):

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 2548, in __call__

  return self.wsgi_app(environ, start_response)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 2528, in wsgi_app

  response = self.handle_exception(e)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 2525, in wsgi_app

  response = self.full_dispatch_request()

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 1822, in full_dispatch_request

  rv = self.handle_user_exception(e)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\app.py", line 1820, in full_dispatch_request

  rv = self.dispatch_request()

 File "C:\Users\cho2\Desktop\sparta\projects\mars\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:\Users\cho2\Desktop\sparta\projects\mars\app.py", line 8, in home

  return render_template('index.html')

 File "C:\Users\cho2\Desktop\sparta\projects\mars\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:\Users\cho2\Desktop\sparta\projects\mars\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:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\jinja2\environment.py", line 1010, in get_template

  return self._load_template(name, globals)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\jinja2\environment.py", line 969, in _load_template

  template = self.loader.load(self, name, self.make_globals(globals))

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\jinja2\loaders.py", line 126, in load

  source, filename, uptodate = self.get_source(environment, name)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\templating.py", line 62, in get_source

  return self._get_source_fast(environment, template)

 File "C:\Users\cho2\Desktop\sparta\projects\mars\venv\lib\site-packages\flask\templating.py", line 98, in _get_source_fast

  raise TemplateNotFound(template)

jinja2.exceptions.TemplateNotFound: index.html

127.0.0.1 - - [10/Aug/2022 08:29:31] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:29:31] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 304 -

127.0.0.1 - - [10/Aug/2022 08:29:32] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 304 -







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