【发布时间】:2018-03-10 18:14:59
【问题描述】:
我的蓝图应该在根目录中查找静态文件,但不是。
假设我有一个名为“前端”的蓝图。 'frontend' 只有 template_folder='frontend' 传入。
即使我将静态文件放在 /app/frontend/static/file.css 下,它也找不到。它也没有在 /app/static/file.css 中找到它。
控制台网络服务器每次都会为每个 css 或 js 静态文件显示“404”。
但是当我打印出 url_maps 时,我确实有这个显示:
<Rule '/static/<filename>' (HEAD, OPTIONS, GET) -> static>])
我就这样启动了 register_blueprint('frontend')。
frontend = Blueprint('frontend', __name__,template_folder='templates')
我在视图中的索引返回:
return render_template('frontend.html', pagination=pagination)
frontend.html只能在/app/frontend/templates工作
如果您将frontend.html 放在/app/templates 上,它也不起作用。即使您删除了“template_folder”参数。
文件结构:
app
-app.py
--frontend
--frontend/templates contains: (frontend.html) (base.html) (errors/404.html)
--static
--static/css (bootstrap.min.css) (what I want to grab with url_for inside base.html)
【问题讨论】: