DEV Community

anbu26
anbu26

Posted on

Flask - Call to a function only once

Hi am new to flask, I want to call a function only once throughout the application. For example Menu. I should load menu related code only once then it should not call that function again. Is there any way to achieve it ?

Top comments (1)

Collapse
 
phondanai profile image
Phondanai

I'm not sure this can help.
Flask has @app.before_first_request decorator, this portion of your code will run only once. May be you can use this to generate your Menu and use it later on.