Expose send_file max-age as config value, #433.
Need to add the same hook in a Blueprint, but this is the first such case where we need app.config in the Blueprint.
This commit is contained in:
parent
146088d580
commit
d94efc6db6
6 changed files with 55 additions and 14 deletions
|
|
@ -249,6 +249,7 @@ class Flask(_PackageBoundObject):
|
|||
'SESSION_COOKIE_HTTPONLY': True,
|
||||
'SESSION_COOKIE_SECURE': False,
|
||||
'MAX_CONTENT_LENGTH': None,
|
||||
'SEND_FILE_MAX_AGE_DEFAULT': 12 * 60 * 60, # 12 hours
|
||||
'TRAP_BAD_REQUEST_ERRORS': False,
|
||||
'TRAP_HTTP_EXCEPTIONS': False
|
||||
})
|
||||
|
|
@ -1020,6 +1021,12 @@ class Flask(_PackageBoundObject):
|
|||
self.error_handler_spec.setdefault(key, {}).setdefault(None, []) \
|
||||
.append((code_or_exception, f))
|
||||
|
||||
def get_send_file_options(self, filename):
|
||||
# Override: Hooks in SEND_FILE_MAX_AGE_DEFAULT config.
|
||||
options = super(Flask, self).get_send_file_options(filename)
|
||||
options['cache_timeout'] = self.config['SEND_FILE_MAX_AGE_DEFAULT']
|
||||
return options
|
||||
|
||||
@setupmethod
|
||||
def template_filter(self, name=None):
|
||||
"""A decorator that is used to register custom template filter.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue