(self, url='/', links=None, body=None, content_type=None)
| 76 | self.app.router.add_route('GET', url, handler) |
| 77 | |
| 78 | def add_page(self, url='/', links=None, body=None, content_type=None): |
| 79 | if not body: |
| 80 | text = ''.join('<a href="{}"></a>'.format(link) |
| 81 | for link in links or []) |
| 82 | body = text.encode('utf-8') |
| 83 | |
| 84 | if content_type is None: |
| 85 | content_type = 'text/html; charset=utf-8' |
| 86 | |
| 87 | @asyncio.coroutine |
| 88 | def handler(req): |
| 89 | yield from req.read() |
| 90 | return web.Response(body=body, headers=[ |
| 91 | ('CONTENT-TYPE', content_type)]) |
| 92 | |
| 93 | self.add_handler(url, handler) |
| 94 | return self.app_url + url |
| 95 | |
| 96 | def add_redirect(self, url, link): |
| 97 | @asyncio.coroutine |
no test coverage detected