My Note/프로젝트 관리
developer community css추가
ELLIE_ing
2021. 11. 12. 21:29
__init__.py에서
/ url의 이름을 index라고 한다.
왜 오른쪽 board.py에서 endpoint='index'로 하지않고 바깥 init파일 / 에서 endpoint를 했을까?
아래 url은 /board이기 때문에
/auth/login -> auth라는 blueprint 안에 있기때문에 auth.login이다.
@bp.route('/')
def index():
# db의 정보를 가져옵니다.
db = get_db()
# 게시글 정보를 모두 가져오는 query를 실행
boards = db.execute(
'SELECT p.id, title, body, created, author_id, username'
' FROM board p JOIN user u ON p.author_id = u.id'
' ORDER BY created DESC'
).fetchall()
return render_template('board/index.html', boards=boards)