[Flask] Sharing a variable to all HTML pages

John Robson John.Robson at usp.br
Thu Jul 21 19:07:56 EDT 2016


Thank you everyone I used "context processors" and works perfectly.

On 07/14/2016 02:31 AM, Mark Pors wrote:
> Have a look at context processors. You can inject variables or functions
> to templates on the app or blueprint level.
>
> See here at the bottom http://flask.pocoo.org/docs/0.11/templating/
>
> Mark
>
>
> On Thursday, July 14, 2016, John Robson
> <John.Robson at usp.br
> <mailto: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
>



More information about the Flask mailing list