Python URL中的默认应用程序

Python URL中的默认应用程序,python,web2py,Python,Web2py,如果我创建应用程序和某个控制器,默认情况下,我将使用以下方式访问它: http://127.0.0.1/application/controller/function 我想改变URL的行为,我可以通过不请求应用程序部分来访问任何控制器。使用我的示例,我希望能够访问我的应用程序的所有控制器,如下所示: http:// 127.0.0.1 /application/controller/function1 http:// 127.0.0.1 /application/controller2/fu

如果我创建应用程序和某个控制器,默认情况下,我将使用以下方式访问它:

http://127.0.0.1/application/controller/function

我想改变URL的行为,我可以通过不请求应用程序部分来访问任何控制器。使用我的示例,我希望能够访问我的应用程序的所有控制器,如下所示:

http:// 127.0.0.1 /application/controller/function1  
http:// 127.0.0.1 /application/controller2/function2
http:// 127.0.0.1 /application/controller2/function3  (and etc.)
http:// 127.0.0.1/controller/function1
http:// 127.0.0.1/controller2/function2
http:// 127.0.0.1/controller2/function3  (and etc.)
我想做的是不再需要指示应用程序能够访问我的所有控制器,如下所示:

http:// 127.0.0.1 /application/controller/function1  
http:// 127.0.0.1 /application/controller2/function2
http:// 127.0.0.1 /application/controller2/function3  (and etc.)
http:// 127.0.0.1/controller/function1
http:// 127.0.0.1/controller2/function2
http:// 127.0.0.1/controller2/function3  (and etc.)

修改my routes.py:

# routes.py
default_application = 'application'
default_controller = 'controller'
default_function = 'index'
我可以访问并重定向到 但是,如果我试图访问其他功能,我需要指示应用程序

我没有找到一个关于如何配置routes.py的很好的参考资料,我想我必须更改这个文件才能得到我想要的

有人能帮我吗


谢谢

中介绍了web2py URL重写功能。注意,您可以在较新的(和较简单的)和替代方案(为更复杂的情况提供了一些额外的灵活性)之间进行选择。在您的情况下,基于参数的系统最简单——只需在
routes.py
文件中包含以下内容:

routers = dict(
    BASE = dict(
        default_application = 'application',
        default_controller = 'controller',
    ),
)
如果你需要额外的帮助,我建议你在网上询问