Python 使用带有路径前缀的cherrypy公开函数

Python 使用带有路径前缀的cherrypy公开函数,python,cherrypy,Python,Cherrypy,cherrypy中是否有方法将函数foo\u test()公开为服务器上的/foo/test端点 下面的示例公开了两个端点/index和/foo_test: class Test(object): @cherrypy.expose def index(self): @cherrypy.expose def foo_test(self): 注: 我已经在@cherrypy.expose(['foo/test'])中使用别名进行了测试,但别名只允许使用字符串和字符串列表 最后

cherrypy中是否有方法将函数
foo\u test()
公开为服务器上的
/foo/test
端点

下面的示例公开了两个端点
/index
/foo_test

class Test(object):

  @cherrypy.expose
  def index(self):

  @cherrypy.expose
  def foo_test(self):
注:

  • 我已经在
    @cherrypy.expose(['foo/test'])
    中使用别名进行了测试,但别名只允许使用字符串和字符串列表

最后,我不得不覆盖
\u cp\u调度
,如中所述


你查过医生了吗?这似乎对你有用我没有看到别名选项,但它们只允许
单个字符串或它们的列表
,所以我不能使用
/
。更新了我的问题。我明白了,最后我不得不覆盖
\u cp\u调度
。文档总是说真话,向上投票;)
class Test(object):

  def __init__(self):
       self.foo = Foo()

  def _cp_dispatch(self, vpath):
       if len(vpath) == 1:
            return self
       if len(vpath) == 2:
            return self.foo
       return self

  @cherrypy.expose
  def index(self):

class Foo(object):

  @cherrypy.expose
  def test(self):