【发布时间】:2017-12-14 17:02:52
【问题描述】:
问题:_cp_dispatch not getting called in cherrypy 澄清了 _cp_dispatch 只有在没有属性/方法与请求匹配时才被调用。
但是,在我的代码中:
import cherrypy
class A(object):
def _cp_dispatch(self, vpath):
raise Exception(str(vpath))
@cherrypy.expose
def index(self):
return "start"
@cherrypy.expose
def method_1(self):
return "method_1"
cherrypy.quickstart(A())
为http://127.0.0.1:8080/garbage 调用_cp_dispatch,但为http://127.0.0.1:8080/method_1/garbage 或http://127.0.0.1:8080/index/garbage 不调用
我也需要为这些调用它。我可以看到 method_1 和 index 作为端点公开,但 没有任何端点method_1/垃圾。那么为什么不调用 _cp_dispatch 呢?
【问题讨论】:
标签: web-services rest cherrypy endpoint