默认路由不起作用

324*_*423 4 python pylons routes

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

我按照文档和http://routes.groovie.org/recipes.html中的说明进行操作,但是当我尝试时,http://127.0.0.1:5000/我只是获得了"欢迎使用Pylons"的默认页面.

我的config/routing.py文件看起来像这样

来自pylons import route from routes import Mapper

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
Run Code Online (Sandbox Code Playgroud)

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

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

map.connect( 'homepage', controller='main', action='index' )
Run Code Online (Sandbox Code Playgroud)

但没有任何作用.我知道它重新加载我的配置文件,因为我使用了paster serve --reload 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))
Run Code Online (Sandbox Code Playgroud)

小智 9

您必须删除静态页面(myapp/public/index.html).由于middleware.py末尾的Cascade配置,静态文件具有优先权.