Skip to content

Instantly share code, notes, and snippets.

@1mh0
Created July 26, 2013 01:15
Show Gist options
  • Select an option

  • Save 1mh0/6085257 to your computer and use it in GitHub Desktop.

Select an option

Save 1mh0/6085257 to your computer and use it in GitHub Desktop.
Bottle: default page callback
@pages_app.get('/:page')
@pages_app.get('/<section:re:(section|another-section)>/:page')
def simple_page(page, section=None):
page_id = request.path.strip('/')
page = Page.get_latest(page_id)
if not page:
return abort(404, "Page not found")
try:
return template('%s.html' % page_id, page=page)
except TemplateError:
return template('pages/default.html', page=page)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment