【问题标题】:Default route doesn't work默认路由不起作用
【发布时间】:2010-11-19 17:56:03
【问题描述】:

我正在使用带有 pylons 的标准路由模块来尝试为我的网站主页设置默认路由。

我已按照文档和此处http://routes.groovie.org/recipes.html 中的说明进行操作,但是当我尝试http://127.0.0.1:5000/ 时,我只会看到“欢迎来到 Pylons”默认页面。

我的 config/routing.py 文件如下所示

从 pylons 导入配置 从路由导入映射器

def make_map():
    """Create, configure and return the routes Mapper"""
    map = Mapper(directory=config['pylons.paths']['controllers'],
             always_scan=config['debug'])
    map.minimization = False

    map.connect('/error/{action}', controller='error')
    map.connect('/error/{action}/{id}', controller='error')

    # CUSTOM ROUTES HERE
    map.connect( '', controller='main', action='index' )
    map.connect('/{controller}/{action}')
    map.connect('/{controller}/{action}/{id}')

    return map

我也试过 map.connect('/', controller='main', action='index')

和(使用http://127.0.0.1:5000/homepage/

map.connect( 'homepage', controller='main', action='index' )

但根本没有任何效果。我知道它会在我使用时重新加载我的配置文件 粘贴服务--重新加载 development.ini 启动服务器

系统信息

$ paster --version
PasteScript 1.7.3 from /Library/Python/2.5/site-packages/PasteScript-1.7.3-py2.5.egg (python 2.5.1 (r251:54863, Feb  6 2009, 19:02:12))

【问题讨论】:

    标签: python routes pylons


    【解决方案1】:

    您必须删除静态页面 (myapp/public/index.html)。静止的 由于末尾的级联配置,文件优先 中间件.py。

    【讨论】:

      猜你喜欢
      • 2012-10-20
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 2020-04-01
      • 2019-05-30
      • 2017-11-27
      相关资源
      最近更新 更多