Page Menu
Home
Search
Configure Global Search
Log In
Files
F14220501
flask_extra.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
755 B
Subscribers
None
flask_extra.py
View Options
import
functools
import
flask
def
add_response_headers
(
headers
:
dict
):
"""This decorator adds the headers passed in to the response"""
def
decorator
(
f
):
@functools.wraps
(
f
)
def
decorated_function
(
*
args
,
**
kwargs
):
resp
=
flask
.
make_response
(
f
(
*
args
,
**
kwargs
))
h
=
resp
.
headers
for
header
,
value
in
headers
.
items
():
h
[
header
]
=
value
return
resp
return
decorated_function
return
decorator
def
vary_xhr
():
"""View function decorator; adds HTTP header "Vary: X-Requested-With" to the response"""
def
decorator
(
f
):
header_adder
=
add_response_headers
({
'Vary'
:
'X-Requested-With'
})
return
header_adder
(
f
)
return
decorator
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Feb 2, 3:02 PM (2 d)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
81/88/e43c7b28f654ce31d3791b3dd9c8
Attached To
rPS Pillar
Event Timeline
Log In to Comment