Working version as a decorator (flask)