| 1 |
from pecan import expose, redirect |
| 2 |
from webob.exc import status_map |
| 3 |
|
| 4 |
|
| 5 |
class RootController(object): |
| 6 |
|
| 7 |
@expose(generic=True, template='index.html') |
| 8 |
def index(self): |
| 9 |
return dict() |
| 10 |
|
| 11 |
@index.when(method='POST') |
| 12 |
def index_post(self, q): |
| 13 |
redirect('https://pecan.readthedocs.io/en/latest/search.html?q=%s' % q) |
| 14 |
|
| 15 |
@expose('error.html') |
| 16 |
def error(self, status): |
| 17 |
try: |
| 18 |
status = int(status) |
| 19 |
except ValueError: # pragma: no cover |
| 20 |
status = 500 |
| 21 |
message = getattr(status_map.get(status), 'explanation', '') |
| 22 |
return dict(status=status, message=message) |