Expand docs on send_file option hook, #433.
This commit is contained in:
parent
f4a31db9f6
commit
146088d580
3 changed files with 21 additions and 5 deletions
|
|
@ -653,8 +653,22 @@ class _PackageBoundObject(object):
|
|||
self.template_folder))
|
||||
|
||||
def get_static_file_options(self, filename):
|
||||
"""Function used internally to determine what keyword arguments
|
||||
to send to :func:`send_from_directory` for a specific file."""
|
||||
"""Provides keyword arguments to send to :func:`send_from_directory`.
|
||||
|
||||
This allows subclasses to change the behavior when sending files based
|
||||
on the filename. For example, to set the cache timeout for .js files
|
||||
to 60 seconds (note the options are keywords for :func:`send_file`)::
|
||||
|
||||
class MyFlask(flask.Flask):
|
||||
def get_static_file_options(self, filename):
|
||||
options = super(MyFlask, self).get_static_file_options(filename)
|
||||
if filename.lower().endswith('.js'):
|
||||
options['cache_timeout'] = 60
|
||||
options['conditional'] = True
|
||||
return options
|
||||
|
||||
.. versionaded:: 0.9
|
||||
"""
|
||||
return {}
|
||||
|
||||
def send_static_file(self, filename):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue