에러문의
1068
5 asked
6분 44초까지 코드 완성했는데 이런 에러가 뜨네요(빌드에러)
이전까지는 다 잘 됐습니다.

제 코드 입니다.
@blueprint.route("/comment_write", methods=["POST"])
@login_required
def comment_write():
if request.method == "POST":
name = session.get("name")
writer_id = session.get("id")
root_idx = request.form.get("rood_idx")
comment = request.form.get("comment")
current_utc_time = round(datetime.utcnow().timestamp() * 1000)
c_comment = mongo.db.comment
post = {
"root_idx": str(root_idx),
"writer_id": writer_id,
"name": name,
"comment": comment,
"pubdate": current_utc_time
}
c_comment.insert_one(post)
return redirect(url_for("board.board_view", idx=root_idx))
아래는 뷰 html 코드입니다.
<form id="commentForm" name="commentForm" action="{{url_for('board.comment_write')}}" method="POST">
<input type="hidden" name="csrf_token" value="{{csrf_token()}}">
<input type="hidden" name="root_idx" value="{{result.id}}">
<div>
<span><strong>댓글</strong></span> <span id="cCnt"></span>
<table class="table">
<tr>
<td><textarea rows="3" cols="110" id="comment" name="comment" playholder="댓글을 입력하세요."></textarea></td>
<td><input type="submit" class="btn btn-success" style="height:80px;" value="등록하기"></td>
</tr>
</table>
</div>
</form>아래는 board_view 코드입니다.
@blueprint.route("/view/<idx>")
@login_required
def board_view(idx):
if idx is not None:
page = request.args.get("page")
search = request.args.get("search")
keyword = request.args.get("keyword")
board = mongo.db.board
#data = board.find_one({"_id": ObjectId(idx)})
data = board.find_one_and_update({"_id": ObjectId(idx)}, {"$inc": {"view": 1}}, return_document=True)
if data is not None:
result = {
"id": data.get("_id"),
"name": data.get("name"),
"title": data.get("title"),
"contents": data.get("contents"),
"pubdate": data.get("pubdate"),
"view": data.get("view"),
"writer_id": data.get("writer_id", ""),
"attachfile": data.get("attachfile", "")
}
return render_template("view.html", result=result, page=page, search=search, keyword=keyword, title="글상세보기")
return abort(404)
그래서 board_view 부분을 바꿨는데요
@blueprint.route("/view")
@login_required
def board_view():
idx = request.args.get("idx")
if idx is not None:
page = request.args.get("page")
search = request.args.get("search")
keyword = request.args.get("keyword")
이런식으로요
그럼 이런 에러가 뜨네요
Answer 3
0
login_required 지우고 했는데도 똑같은 에러가 발생하네요..
6분44초 전까지는 다 잘 됐었는데..
다른 데서 로그인체크기능도 잘 작동하는데..
@blueprint.route("/comment_write", methods=["POST"])
def comment_write():
if request.method == "POST":
name = session.get("name")
writer_id = session.get("id")
root_idx = request.form.get("rood_idx")
comment = request.form.get("comment")
current_utc_time = round(datetime.utcnow().timestamp() * 1000)
c_comment = mongo.db.comment
post = {
"root_idx": str(root_idx),
"writer_id": writer_id,
"name": name,
"comment": comment,
"pubdate": current_utc_time
}
c_comment.insert_one(post)
return redirect(url_for("board.board_view", idx=root_idx))BuildError
werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'board.board_view'. Did you forget to specify values ['idx']?
Traceback (most recent call last)
File "c:\Python\myweb\venv\lib\site-packages\flask\app.py", line 2091, in
__call__return self.wsgi_app(environ, start_response)File "c:\Python\myweb\venv\lib\site-packages\flask\app.py", line 2076, in
wsgi_appresponse = self.handle_exception(e)File "c:\Python\myweb\venv\lib\site-packages\flask\app.py", line 2073, in
wsgi_appresponse = self.full_dispatch_request()File "c:\Python\myweb\venv\lib\site-packages\flask\app.py", line 1519, in
full_dispatch_requestrv = self.handle_user_exception(e)File "c:\Python\myweb\venv\lib\site-packages\flask\app.py", line 1517, in
full_dispatch_requestrv = self.dispatch_request()File "c:\Python\myweb\venv\lib\site-packages\flask\app.py", line 1503, in
dispatch_requestreturn self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)File "c:\Python\myweb\main\board.py", line 39, in
comment_writereturn redirect(url_for("board.board_view", idx=root_idx))File "c:\Python\myweb\venv\lib\site-packages\flask\helpers.py", line 336, in
url_forreturn appctx.app.handle_url_build_error(error, endpoint, values)File "c:\Python\myweb\venv\lib\site-packages\flask\helpers.py", line 323, in
url_forrv = url_adapter.build(File "c:\Python\myweb\venv\lib\site-packages\werkzeug\routing\map.py", line 917, in
buildraise BuildError(endpoint, values, method, self)
werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'board.board_view'. Did you forget to specify values ['idx']?
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 framedump(obj)dumps all that's known about the object


0
웹사이트는 부분적인 코드만 봐서는 오류의 원인을 알수없습니다.
첫번째 오류는 아마도 데코레이터로 설정된 함수에서 발생하는 오류로 보입니다. login_required 로 데코레이터 된 함수를 확인해보셔야 할 듯 합니다.
iis 접속후 자동으로 로그인 창이 나오도록 설정이 기능한가요?
0
63
2
리스트 이동 시 창 에러 발생
0
73
1
배포후 회원 등록 후 로그인 에러...
0
72
2
내부 서버 오류
0
66
2
app.config["MONGO_URI"] = "mongodb://localhost:27017/pm_db"
0
53
2
DB 검색하면 데이터가 없습니다. 라고 나와요. 5시간을 찾아봐도 모르겠어서 문의드려봅니다.
0
44
1
몽고db studio3T를 깔았는데
0
57
2
flake8과 linter
0
72
3
500이 뜹니다.
0
57
2
첨부파일 삭제
0
66
2
검색기능 질문
0
61
2
google.py
0
66
2
Studio 3T에 DB insert가 되지 않는 문제를 해결하지 못하고 있습니다 ㅠ
0
81
3
혹시 전체 코드 공개되어 있나요?
0
95
1
join.html 의 form 태그값 을 member_join() 에서 처리못함.
0
102
1
google.py 몽고db 샘플데이터 만들기
0
99
2
flake8 설치 이후 명령팔레트에서 linter가 안보입니다.
0
236
2
파이썬으로 만들어서 웹호스팅에 올릴경우
0
303
1
현재 구글검색 무한스크롤변경 문의합니다
0
295
1
몽고디비아틀라스로 추가 공부해서 올립니다.
0
216
1
IIS 500.19에러
0
653
2
버전 문제도 수정했는데 결과가 안나옵니다.
0
255
1
데이터베이스 저장관련 질문입니다.
0
266
1
test가 생기지 않습니다.
0
501
3

