is there a way to list all defined routes?

17 views
Skip to first unread message

Alfonso Serra

unread,
Aug 20, 2025, 5:03:43 AMAug 20
to py4web
I would like to list all the defined routes in an application to dynamically build the  navigation layout. Is there a way to list them all?  

Thanks!
Best Regards

laundmo

unread,
Aug 20, 2025, 7:06:55 AMAug 20
to py4web
Hi,

You can do something like this, since py4web uses ombott for routing and handling things:

@action("test")
def test():
    import Abbott

    for route in ombott.app.routes.values():
        print(route.rule)
        for method, handler in route.methods.items():
            print(f"\t{method} - {handler.handler_fullname}")
    return {}

example output:

/_dashboard/ticket/<ticket_uuid>
        GET - apps._dashboard.error_ticket
        POST - apps._dashboard.error_ticket

hope that helps

laundmo

unread,
Aug 20, 2025, 7:07:59 AMAug 20
to py4web
oops, somehow by pasting in my browser autocorrected "import ombott" to "import Abbott" - you'll need to fix that ofc!
Reply all
Reply to author
Forward
0 new messages