我的藍圖應該在根目錄下尋找靜態文件,但事實並非如此。燒瓶藍圖尋找藍圖中的靜態文件而不是根目錄
說我有一個名爲「前端」藍圖。 「前端」只有在。
過去了就算我把靜態文件下/app/frontend/static/file.css template_folder =「前端」,它沒有找到它。它也沒有在/app/static/file.css中找到它。
控制檯Web服務器,以便每次每個CSS或JS靜態文件說:「404」。
但我做的時候我打印出來url_maps有這樣的表現:
<Rule '/static/<filename>' (HEAD, OPTIONS, GET) -> static>])
我發起register_blueprint( '前端')這樣的。
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)
我的意思是不是哲學上的設計,以便您可以從「root/app/static」目錄中「common」static_files以及從/ app/blueprint/static文件夾中獲取特定於藍圖的文件?它不應該檢查默認情況下,否則每個藍圖將重複相同的文件?我認爲它應該是標準的,它應該首先看ROOT靜態,然後在藍圖的靜態。 – Dexter
有點不同意,因爲藍圖更獨立,比如你可以使用admin模塊,使用1.9.0的jquery.js和2.0.0的jquery.js使用主應用程序。另外一些文件可以具有相同的名稱,如'styles.css'。只是我的意見:如果藍圖不使用應用程序靜態,則爲靜態應用程序和藍圖使用不同的URL。 – tbicr