Add web search and page retrieval to Toolbox

This commit is contained in:
Mark Gregory
2026-11-16 15:14:10 +00:00
parent 32c4b9f91c
commit 49140e0863
8 changed files with 246 additions and 20 deletions
+10
View File
@@ -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 &amp; 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)