Since Flask uses route() decorator to bind a function to a URL (Routing), this blog gives naive decorators and its corresponding code without decorator.
Level 1 (no parameters)
1 | def wrapper(func): |
Corresponding decorator :
1 | def wrapper(func): |
output:
start
logging
end
Level 2 (require parameter for log)
1 | def wrapper(func): |
Corresponding decorator :
1 | def wrapper(func): |
output:
start
logging file
end
Level 3 (Require parameter for decorator)
1 | def wrapper(path_name): |
Corresponding decorator:
1 | def wrapper(path_name): |
output:
start logging in path
logging
end
Level 4 (Require parameter for decorator&log)
1 | def wrapper(path_name): |
Corresponding decorator :
1 | def wrapper(path_name): |
output:
start logging in path
logging file
end