Write a Lightweight Route Decorator in Python

John Raines
5 min readDec 10, 2022
Photo by Brendan Church on Unsplash

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.

--

--

John Raines

For money, I’m a software engineer who primarily works in machine learning platform design. For free, I read fantasy novels and raise children (my own).