Skip to content

Flask-Bootstrap

安装

shell
pip install flask-bootstrap

官方文档: https://getbootstrap.com/docs/4.1/getting-started/introduction/

404

python
@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

500

python
@app.route('/server_error')
def server_error():
    abort(500)
    return render_template("bootstrap.html",name="diyai1314")

@app.errorhandler(500)
def internal_server_error(e):
    return render_template('500.html'), 500

静态文件

创建static 目录,并将文件放到该目录下,该目录会被映射到static路由下

例如访问: http://localhost:9999/static/test.txt

查看源码

https://gitee.com/PatrickW/flask-web/blob/master/src/5bootstrap.py