在templates/front/下创建详情页面front_pdetail.html

编辑front.views.py创建详情页的视图函数

from flask import abort
...

@bp.route('/p/<post_id>/')
def post_detail(post_id):
    post = PostModel.query.get(post_id)
    if not post:
        abort(404)
    return render_template('front/front_pdetail.html', post=post)

上面写了,如果帖子不存在,则返回404,我们先创建个404页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>BBS论坛404页面</title>
</head>
<body>
    您要找的页面已经到火星去了~~
    <div>
        <a href="/">回到首页</a>
    </div>
</body>
</html>
front_404.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2021-08-18
  • 2021-10-24
  • 2021-11-26
  • 2022-02-11
  • 2021-10-14
猜你喜欢
  • 2021-08-29
  • 2021-09-09
  • 2021-12-03
  • 2021-09-17
  • 2021-10-01
  • 2021-12-28
  • 2021-05-20
相关资源
相似解决方案