'before_filter' equivalent w / bulb

After some time working with ruby, I will return to python. I work with a flask.

How to implement a filter to start a method in a request when starting a controller action without sending the same code to each controller? My first guess is to build some kind of decorator (for example, @before_request, but this did not seem at first glance). I just get (re) getting to know python, and there are a few things that are not available, so any input is appreciated. Equivalent is before_filter in Rails or before that in Sinatra.

+4
source share
1 answer

There is a constructor @app.before_request , as shown in the SQLite template specified in the docs. This is done for every request.

+1
source

Source: https://habr.com/ru/post/1410926/


All Articles