代码之家  ›  专栏  ›  技术社区  ›  EMP

我如何在塔架中设置默认页面?

  •  2
  • EMP  · 技术社区  · 14 年前

    我创建了一个新的Pylons应用程序,并添加了一个带有模板(“index.mako”)的控制器(“main.py”)。现在是URL http://myserver/main/index http://myserver/ ?

    def make_map():
        """Create, configure and return the routes Mapper"""
        map = Mapper(directory=config['pylons.paths']['controllers'],
                     always_scan=config['debug'])
        map.minimization = False
    
        # The ErrorController route (handles 404/500 error pages); it should
        # likely stay at the top, ensuring it can always be resolved
        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
    

    我还删除了 public 目录(favicon.ico除外),位于 Default route doesn't work

    2 回复  |  直到 7 年前
        1
  •  3
  •   Robert Kluin    14 年前

    试试这个: map.connect('/', controller='main', action='index')

        2
  •  2
  •   heen    14 年前