问题
Is there a way to get CherryPy to respond to a url that includes a period, such as http://some/base/path/oldscript.py
? I have a number of old CGI scripts that were called like that, and I'm trying to roll them into a nice pretty CherryPy web app - but I don't want to break all the bookmarks and the like that still point to the CGI scripts. Ideally the same method would respond to the url regardless of if it has a .py or not.
回答1:
Turns out using an _ in the method definition works as a dot/period. This does mean I have to have two function definitions if I want to be able to call it either with or without the .py, but since I can easily call the one function from the other, this is a minor quibble.
来源:https://stackoverflow.com/questions/23436414/cherrypy-respond-to-url-that-includes-a-dot