Learn to Code ยท zero-dependency ยท MIT

larzrouter

URL routing like a web framework.

Routing is the heart of every web framework: taking an incoming URL and deciding which function handles it, pulling out the parts (like an id) along the way. larzrouter does exactly that in code you can read - path params, matching, and building URLs back.

larzscript pkg install router
View on GitHub →Learn the stack

What you get

Try it

import "router" as router
let r = router.new()
router.add(r, "/users/<int:id>", "get_user")
router.add(r, "/users/<name>/posts", "user_posts")
let m = router.match(r, "/users/42")
print(m["handler"], m["params"])
print(router.build("/users/<int:id>", {"id": 42}))
Output
get_user {id: 42}
/users/42

Why it's in the Larz Stack

larzrouter is a real Larzscript package (larzscript pkg install router) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.