I have been working with Flask.route() decorator for a while and wanted to write my own, but it always tells me that the function isn't passed into it.
I've copied everything exactly like in the Flask examples, so my decorator definition must be wrong:
def decorator(f, *d_args):
def function(*args, **kwargs):
print('I am decorated')
return f(*args, **kwargs)
return function
@decorator()
def test(a, b=1):
print('Test', a, b)
test(1, 6)
The error I get:
Traceback (most recent call last):
File "C:/Users/Tobi/Desktop/decorators.py", line 49, in <module>
@decorator()
TypeError: decorator() missing 1 required positional argument: 'f'