Black Lives Matter. Please consider donating to Black Girls Code today.

URL routing processed all on one page, or in sub-modules?

Let’s use the Dash example and say we have an app that routes like so:

@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/apps/app1':
        return app1.layout
    elif pathname == '/apps/app2':
        return app2.layout
    else:
        return '404'

If app1 needs to do additional parsing, for example, say the pathname was /apps/app1/edit, is it better to detect the first part of the pathname in the string (“app1”), then pass it along to a router in app1, which would extract the ‘edit’ parameter from the pathname and do whatever it needs to do?

The other way to do it would be to have an entry for all the possibilities on the routing page:
/apps/app1/
/apps/app1/edit
/apps/app1/view
etc…

I’m guessing the former method is the better way to go because then the router doesn’t need to know the details of app1, but I wanted to ask if there was any reason I should keep all the routing on one page since I’m fairly new to development in flask/dash.