I'm doing something similar, as I convert an
asp.net application.
my url mapping:
urls = (
'/', 'index',
'/uiMethods/(.*)', 'uiMethods'
)
This way, anything that hits /uiMethods/foo is a web method call, and
I can still do normal mappings for static pages, templates, etc.
I then use the following handler for GET and POST, which in turn call
the function by *name*
class uiMethods:
def GET(self, method):
try:
methodToCall = getattr(self, method)
result = methodToCall()
return result
except Exception as ex:
raise ex
def POST(self, method):
try:
methodToCall = getattr(self, method)
result = methodToCall()
return result
except Exception as ex:
raise ex
def hello(self):
print "hello"
So, localhost:8080/uiMethods/hello will now map to your function, and
you can add new functions all day long without messing around with
more url mappings.