我正在开发一个使用蓝图的应用程序,我按照文档快速启动了蓝图,但我的模板上仍然有404。
我有一个admin的蓝图,看起来是这样的:
from flask import Blueprint, render_template
admin = Blueprint('admin', __name__, template_folder='templates')
@admin.route('/')
def admin_index():
return render_template('admin/index.html.jinja2')如文档中所述,我的模板位于/myapp/admin/ template /index.html.jinja 2+中。
我在我的应用程序__init__.py文件中注册了蓝图:
from flask import Flask
from . import config
from admin import admin
app = Flask(__name__)
app.config.from_object(config.DevelopmentConfig)
# register my blueprint
app.register_blueprint(admin, url_prefix='/admin/')如果有人对我可能犯的错误有想法,请告诉我!
发布于 2013-07-28 11:08:05
你对文档不准确。你的模板应该在
myapp/admin/templates/admin/index.html.jinja2注意admin文件夹在templates中。
https://stackoverflow.com/questions/17906513
复制相似问题