Skip to content
Myr

document blueprint static folder without prefix

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 16d83d6 · Browse files · 1 file+17 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−9 removed

  • other:+17 added−9 removed

1 file+17 added−9 removed

modified:docs/blueprints.rst+17 added-9 removed
149 unmodified lines
150151Static Files152````````````153154A blueprint can expose a folder with static files by providing a path to a155folder on the filesystem via the `static_folder` keyword argument. It can156either be an absolute path or one relative to the folder of the157blueprint::154A blueprint can expose a folder with static files by providing the path155to the folder on the filesystem with the ``static_folder`` argument.156It is either an absolute path or relative to the blueprint's location::157158 admin = Blueprint('admin', __name__, static_folder='static')159160By default the rightmost part of the path is where it is exposed on the162web. Because the folder is called :file:`static` here it will be available at163the location of the blueprint + ``/static``. Say the blueprint is164registered for ``/admin`` the static folder will be at ``/admin/static``.161web. This can be changed with the ``static_url`` argument. Because the162folder is called ``static`` here it will be available at the163``url_prefix`` of the blueprint + ``/static``. If the blueprint164has the prefix ``/admin``, the static URL will be ``/admin/static``.165166The endpoint is named `blueprint_name.static` so you can generate URLs to167it like you would do to the static folder of the application::166The endpoint is named ``blueprint_name.static``. You can generate URLs167to it with :func:`url_for` like you would with the static folder of the168application::169170 url_for('admin.static', filename='style.css')171172However, if the blueprint does not have a ``url_prefix``, it is not173possible to access the blueprint's static folder. This is because the174URL would be ``/static`` in this case, and the application's ``/static``175route takes precedence. Unlike template folders, blueprint static176folders are not searched if the file does not exist in the application177static folder.178179Templates180`````````181182If you want the blueprint to expose templates you can do that by providing
92 unmodified lines