Write a Lightweight Route Decorator in Python
5 min readDec 10, 2022
If you’ve used an API framework or two (I love Flask), then you’ve seen this strategy at work. What you might not realize is that it’s saving you the pain and anguish of writing a ton of if..elif..else
statements. Under the right conditions, a route decorator is a great way to separate concerns and eliminate control flow in any number of application types — not just APIs.