Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

蓝图自定义模板文件夹template_folder注意点:

如果app/templates中有index.html
并且app/cms/templates也有index.html文件
渲染模板会优先查找app/templates目录下。
蓝图如果要正常使用,创建规则必须是app/cms/templates/cms/index.html,渲染render_template('cms/index.html') 完整例子:

bp = Blueprint('cms', __name__, url_prefix='/cms', template_folder='templates')

@bp.route('/cms/index')
def index():
  return render_template('cms/index.html')

flask模板查找规则是优先项目根目录``