My project has four web.py servers running - a UI, and admin UI, a reporting server and a rest api. The admin ui is pure ajax, so I have about 20 "pages" with traditional urls, but each page is capable of making dozens of ajax calls, each also a url, totalling several hundred urls.
Rather than explicitly define all the urls in my root module, I've done this:
* I have code split into modules by functional groupings (user management in one, reports in one, etc)
* I have a common.py module that has references to web, app and session, plus anything else I'd want to share across my two dozen modules.
* my "pages" are served from templates, just like the template examples, "return render(home)"... etc.
* my app.py main program, rather than having the hundreds of ajax endpoints explicitly defined, instead has one primary handler function - wmHandler. Looks like this (scrubbed of course):
urls = (
'/home', 'home',
'/(.*)', 'wmHandler'
)
My handler:
class wmHandler:
#the GET and POST methods here are hooked by web.py.
#whatever method is requested, that function is called.
def GET(self, method):
return common.FindAndCall(method)
def POST(self, method):
return common.FindAndCall(method)
The FindAndCall method in a nutshell does python magic to find the right module, import it, and exec the right function. It's pretty complex, and not really relevant to your original question.
Hope this helps!
S