我的蓝图应该在根目录中查找静态文件,但事实并非如此。
假设我有一个名为“前端”的蓝图。 '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
at /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)