2017-01-05 7 views
1

テンプレートと静的ファイルを含むFlaskブループリントがあります。テンプレートは正しく表示されますが、リンクされたCSSファイルは404が見つかりません。青写真のフォルダの下にある静的ファイルはどのように提供しますか?Flaskブループリントフォルダの下にある静的ファイルを処理します

app/ 
    __init__.py 
    auth/ 
    __init__.py 
    static/ 
     style.css 
    templates/ 
     index.html 
auth = Blueprint('auth', __name__, template_folder='templates') 

@auth.route('/') 
def index(): 
    return render_template('index.html') 
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}"> 

答えて

2

その静的なフォルダが青写真のstaticルートへのURLを生成するためにurl_forを使用し、その後、static_folderを渡すことである青写真を知らせます。 This is described in the docs.

auth = Blueprint('auth', __name__, template_folder='templates', static_folder='static') 
url_for('auth.static', filename='style.css') 
関連する問題