Replies: 1 comment
-
|
Decorators are a standard feature of the Python language. I have written a series of articles on my blog that explain how they work: https://blog.miguelgrinberg.com/post/the-ultimate-guide-to-python-decorators-part-i-function-registration. The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running microdot on an esp32, it's a great framework!!!
I have a generic question trying to understand in the code of 'microdot.route()...'
My question is, how does the decorator route(...) work, without having the function as parameter 'f' but it is used in decorated(f) to register (same for get,del, patch,....). For after_request(self, f) or before_request(self, f) this is different. What insights am I missing here to understand from decorator usage.
def route(self, url_pattern, methods=None):
def decorated(f):
self.url_map.append(
([m.upper() for m in (methods or ['GET'])],
URLPattern(url_pattern), f, '', None))
return f
return decorated
Beta Was this translation helpful? Give feedback.
All reactions