#!/usr/bin/env python3
"""Synthetic, read-only Items API. Local demonstration, not a production connector."""
import json
from http.server import BaseHTTPRequestHandler, HTTPServer


class ItemsHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        found = self.path == "/items"
        payload = {"items": [{"id": "item-1"}]} if found else {"error": "not_found"}
        body = json.dumps(payload).encode("utf-8")
        self.send_response(200 if found else 404)
        self.send_header("Content-Type", "application/json; charset=utf-8")
        self.send_header("Content-Length", str(len(body)))
        self.end_headers()
        self.wfile.write(body)


if __name__ == "__main__":
    print("Synthetic Items API: http://127.0.0.1:18761/items", flush=True)
    HTTPServer(("127.0.0.1", 18761), ItemsHandler).serve_forever()
