cherrypy: respond to url that includes a dot?

孤街浪徒 提交于 2019-12-24 12:44:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!