Answer the question
In order to leave comments, you need to log in
How to make a decorator for all routes in Flask?
I have many routes, and they all have one decorator attached to them. How can I make it so that it is not necessary to prescribe a decorator for each route, but it is somehow automatically added?
Answer the question
In order to leave comments, you need to log in
This can be done, for example, by introspection. But this is very implicit, in python it is not accepted. The essence is this: you go through the module, look for all the functions, create routes based on their names and knit functions to them.
You can make a router like in django. IMHO, this is a much better solution, which allows you not to build an architecture turned inside out, like a flask with circular dependencies and routes that you can find.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question