[Flask] Sharing a variable to all HTML pages

Graham Cleven graham.cleven at gmail.com
Thu Jul 14 02:11:48 EDT 2016


Just a thought, the g variable is available to all render templates. Maybe
try saving your vars to that?
-Graham

On Thu, Jul 14, 2016 at 1:51 AM, John Robson <John.Robson at usp.br> wrote:

> Hi everyone,
>
> I would like to pass several variables to all HTML pages, how can I send a
> variable to all HTML pages, without pass it all the time through "
> *render_template*"? eg: sending "time" to all HTML pages
>
> *site.html*
> *Last Update: {{ update }}*
>
> *app.py*
> *  update = '2016-07-14 01:37:56'*
> *  return render_template('site.html', update=update)*
>
> But how to pass this value every time to all HTML pages automatically?
> Just:
> * return render_template('site.html')*
>
> And the value 'update' will be there.
>
> Thank you for helping,
> John
>
> _______________________________________________
> 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/20160714/fbad9624/attachment.html>


More information about the Flask mailing list