Take a look at flask.make_response
"Sometimes it is necessary to set additional headers in a view. Because views do not have to return response objects but can return a value that is converted into a response object by Flask itself, it becomes tricky to add headers to it. This function can be called instead of using a return and you will get a response object which you can use to attach headers.
def index():
response = make_response(render_template('index.html', foo=bar))
# add your P3P header to the response
response.headers['P3P] = 'xxxx'
return response