0

The normal way of sending data to HTML that I know of is

data = ['a','b','c']
return render_template('index.html', my_data=data)

However, say I have 10+ routes that I have to keep track of, is there a more efficient way to globally send data to every route without having to explicitly say so in every instance of render_template()?

The reason for this is I have used Auth0 to create the login, now I have the user_info which contains their name and display picture, etc, this gets stored in the session['profile']. It'd be nice to send this information to every route so that I can display

IMG | Username | [log out]

In the Navbar on every page, without having to include it in the render template method every time for every instance. Is there something like this?

Ari
  • 5,301
  • 8
  • 46
  • 120
  • 2
    You need a context processor, first Google result for "flask include data in every template": https://stackoverflow.com/questions/26498689/flask-jinja-pass-data-to-a-base-template-all-templates – boreq Jun 01 '19 at 00:09
  • @boreq cheers, that worked. – Ari Jun 01 '19 at 00:17

0 Answers0