[Flask] Flask Digest, Vol 17, Issue 6

Chukwudi Nwachukwu hsysinfo at gmail.com
Sat Nov 19 00:37:47 EST 2016


Hello John,

In an after request, do something like this:
https://gist.github.com/nwaomachux/81dcc1450cf69a2f34c4d42730a1b4c3#file-after_request-py
Then just *render_template('response.html' ** templateData) *at the normal
place and that would be it.


*iChux*™
https://ng.linkedin.com/in/ichux
http://stackoverflow.com/story/nwaomachux
<http://stackoverflow.com/users/2787992/ichux>

*Behind every no entry sign, there is a door.*

On 18 November 2016 at 18:00, <flask-request at python.org> wrote:

> Send Flask mailing list submissions to
>         flask at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/flask
> or, via email, send a message with subject or body 'help' to
>         flask-request at python.org
>
> You can reach the person managing the list at
>         flask-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Flask digest..."
>
> Today's Topics:
>
>    1. Templatizing HTTP Response Headers (John Overbaugh)
>    2. Re: Templatizing HTTP Response Headers (Can Hosgor)
>
>
> ---------- Forwarded message ----------
> From: John Overbaugh <joatgm at gmail.com>
> To: flask at python.org
> Cc:
> Date: Thu, 17 Nov 2016 13:01:09 -0700
> Subject: [Flask] Templatizing HTTP Response Headers
> In a Flask web app I'm building, I have a number of pages. Each page has
> essentially the same HTTP response headers, such as:
>     r = make_response(render_template('response.html' **templateData))
>     r.headers.set('Content-Security-Policy', "default-src 'self';
> script-src 'nonce-" + str(scriptNonce) + "' 'self'")
>     r.headers.set('X-XSS-Protection', '1; mode=block')
>     r.headers.set('X-Content-Type-Options', 'nosniff')
>     r.headers.set('X-Frame-Options', 'deny')
>     r.headers['Server'] = '' # Can't remove it, so set it to nothing
>     return r
>
> Is there a way to templatize this, so it's the same for every page?
>
> John O.
>
>
> ---------- Forwarded message ----------
> From: Can Hosgor <canhosgor at gmail.com>
> To: John Overbaugh <joatgm at gmail.com>, flask at python.org
> Cc:
> Date: Thu, 17 Nov 2016 20:27:17 +0000
> Subject: Re: [Flask] Templatizing HTTP Response Headers
> You can use @app.after_request decorator to make flask call your function
> (in which you can modify the response as you like) at the end of every
> request.
>
> 17 Kas 2016 Per, saat 23:09 tarihinde John Overbaugh <joatgm at gmail.com>
> şunu yazdı:
>
>> In a Flask web app I'm building, I have a number of pages. Each page has
>> essentially the same HTTP response headers, such as:
>>     r = make_response(render_template('response.html' **templateData))
>>     r.headers.set('Content-Security-Policy', "default-src 'self';
>> script-src 'nonce-" + str(scriptNonce) + "' 'self'")
>>     r.headers.set('X-XSS-Protection', '1; mode=block')
>>     r.headers.set('X-Content-Type-Options', 'nosniff')
>>     r.headers.set('X-Frame-Options', 'deny')
>>     r.headers['Server'] = '' # Can't remove it, so set it to nothing
>>     return r
>>
>> Is there a way to templatize this, so it's the same for every page?
>>
>> John O.
>> _______________________________________________
>> Flask mailing list
>> Flask at python.org
>> https://mail.python.org/mailman/listinfo/flask
>>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20161119/321c0cd7/attachment.html>


More information about the Flask mailing list