【发布时间】:2010-03-09 04:14:28
【问题描述】:
我创建了一个新的 Pylons 应用程序并添加了一个带有模板(“index.mako”)的控制器(“main.py”)。现在 URL http://myserver/main/index 有效。我如何使它成为默认页面,即。当我浏览到http://myserver/ 时返回的那个?
我已经在 routing.py 中添加了默认路由:
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 的回答,现在我只收到错误 404。
我还需要做什么才能让这样一个基本的事情发挥作用?
【问题讨论】: