views:

168

answers:

2

I've created a new Pylons application and added a controller ("main.py") with a template ("index.mako"). Now the URL http://myserver/main/index works. How do I make this the default page, ie. the one returned when I browse to http://myserver/ ?

I've already added a default route in 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

I've also deleted the contents of the public directory (except for favicon.ico), following the answer to http://stackoverflow.com/questions/1279403/default-route-doesnt-work Now I just get error 404.

What else do I need to do to get such a basic thing to work?

+1  A: 

Try this: map.connect('/', controller='main', action='index')

Robert Kluin
Pylons uses routes, these docs are very useful when getting started with routes: http://routes.groovie.org/setting_up.html
Robert Kluin
That works - thanks! I could have sworn I saw '' in the file I copied from, not '/'.
Evgeny
+1  A: 

You need to remove public/index.html file to make / routing rule work. Otherwise it is served directly.

heen