Add web search and page retrieval to Toolbox
This commit is contained in:
@@ -96,6 +96,16 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.reply(200, envelope, headers=headers)
|
||||
|
||||
def do_GET(self):
|
||||
if self.path == '/search?q=tides+%26+moon&format=json' or self.path == '/search?q=tides%20%26%20moon&format=json':
|
||||
page = f'http://127.0.0.1:{self.server.server_port}/article'
|
||||
self.reply(200, {'results': [
|
||||
{'url': page, 'title': '<b>Moon and tides</b>', 'content': 'A fixture & summary'},
|
||||
{'url': 'file:///etc/hosts', 'title': 'Invalid'},
|
||||
{'url': page, 'title': 'Duplicate'}]})
|
||||
return
|
||||
if self.path == '/article':
|
||||
self.reply(200, b'<h1>Moon and tides</h1><script>ignored()</script><p>Test passage.</p>', 'text/html')
|
||||
return
|
||||
if self.path == '/compatible/v1/models':
|
||||
if self.headers.get('Authorization') != 'Bearer fixture-token':
|
||||
self.reply(401)
|
||||
|
||||
Reference in New Issue
Block a user