cherrypy:响应包含点的网址吗? [英] cherrypy: respond to url that includes a dot?
问题描述
是否有办法让CherryPy响应包含句点的URL,例如 http://some/base/path/oldscript.py
?我有许多这样的旧CGI脚本,我正尝试将它们滚动到一个漂亮的漂亮CherryPy Web应用程序中-但我不想破坏所有书签,而这些书签仍指向CGI脚本.理想情况下,无论是否具有.py,相同的方法都将对url进行响应.
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.
推荐答案
在方法定义中使用_的结果是点/句点.这的确意味着如果我希望能够使用或不使用.py进行调用,都必须具有两个函数定义,但是由于我可以轻松地从另一个调用一个函数,因此这是一个小问题.
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.
这篇关于cherrypy:响应包含点的网址吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!