我正在玩web2py url重写。应用程序的名称是py2manager,我想通过代码在web2py中将其设为默认值:
# vim py2manager/routes.py:
routers = dict(
BASE = dict(
default_application='py2manager',
)
)但是在web2py重启后,我无法访问这个页面的http://localhost:8000/user/login (它应该与旧的http://localhost:8000/py2manager/default/user/login相同,并且旧的可以正常工作)。不知何故,我找不到用于调试的日志。
我的web2py版本是从git克隆的2.14.6-stable+timestamp.2016.05.09.19.18.48。
如何在省略py2manager/default路径的情况下进行正确重写。
附言:作为医生,我使用了官方的man http://web2py.com/books/default/chapter/29/04/the-core#URL-rewrite
发布于 2017-02-07 03:05:17
默认函数是index,因此路由器需要更多信息来区分对/index/user/login (其中user和login都是index函数的参数)和/user/login (其中login是user函数的参数)的请求。为此,您必须指定相关控制器中的函数列表:
routers = dict(
BASE = dict(
default_application='py2manager',
),
py2manager = dict(
default_controller='default',
default_function='index',
functions=dict(
default=['index', 'user', 'list', 'of', 'other', 'functions']
)
)
)此外,如果可能,您应该使用URL()函数来生成URL,因为它始终会根据路由器的配置为给定的路由生成适当的URL。
发布于 2017-02-10 06:38:43
路由可能需要重新加载。
如果您转到管理。在右上角,Change Admin Password按钮旁边是Reload Routes按钮。
https://stackoverflow.com/questions/42073896
复制相似问题