Flask 有一个 url_for 方法调用,用于从其全局设置文件夹中设置 url。
我如何管理与 CherryPy 类似的事情?
最佳答案
这是您要找的吗?
您可以通过以下方式访问已安装的 url 处理程序
cherrypy.tree.apps[mount_point].root
root 始终是挂载点的挂载实例。所以反向函数看起来像:
def reverse(cls):
# get link to a class type
for app_url in cherrypy.tree.apps.keys():
if isinstance(cherrypy.tree.apps[app_url].root, cls):
# NOTE: it will return with the first mount point of this class
return app_url
how to get url of an object in cherrypy?
希望这有帮助!
关于python - CherryPy 是否有 url_for 的替代方案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21045092/