In Flask, I would like to understand how to create a function that behaves similar to current_user in the sense that it is available everywhere (controllers and views) but I'm struggling to actually know what to search for to find the answer.
The closest post on SO that I've been able to find is this one, but it's for Ruby rather than Python, could someone point me in the right direction? Thanks!
What I have so far:
In my __main__.py I have this:
@app.context_processor
def foo_processor():
def foo():
return 'Hello World'
The result of this is that I can access {{ foo }} in my Jinja templates without having to send it through from my controller. Unfortunately, I can't access foo within my controllers, and this is what I would like to also be able to do. Do I need to import it somehow, and if I do, how?