MCPcopy
hub / github.com/aosabook/500lines / add_page

Method add_page

crawler/code/test.py:78–94  ·  view source on GitHub ↗
(self, url='/', links=None, body=None, content_type=None)

Source from the content-addressed store, hash-verified

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

Callers 8

test_linkMethod · 0.95
test_link_cycleMethod · 0.95
test_prohibited_hostMethod · 0.95
test_max_tasksMethod · 0.95
test_charsetMethod · 0.95
test_content_typeMethod · 0.95
test_non_htmlMethod · 0.95
test_non_httpMethod · 0.95

Calls 2

add_handlerMethod · 0.95
joinMethod · 0.80

Tested by

no test coverage detected