# This is a controlled Python script (.dspy file) that will be executed by the web framework # It provides the API endpoint for /hermes-web-cli/services/list import json from hermes_web_cli.init import get_all_services def main(): """Main function to handle the services list API request for select dropdowns.""" try: # Get all services from the module services = get_all_services() # Format for select dropdown (value, label pairs) service_options = [] for service in services: service_options.append({ "value": service.get("id"), "label": service.get("name", f"Service {service.get('id')}") }) # Return as JSON response return { "status": "success", "data": service_options, "total": len(service_options) } except Exception as e: return { "status": "error", "message": str(e), "data": [], "total": 0 } # Execute and return JSON response result = main() print(json.dumps(result, ensure_ascii=False))