- Added all missing .ui files referenced in index.ui:
* new_session.ui
* sessions.ui
* services.ui
* settings.ui
* session_detail.ui
* add_service.ui
* edit_service.ui
- Created corresponding .dspy API endpoints with proper directory structure:
* /hermes-web-cli/services → services/index.dspy
* /hermes-web-cli/services/list → services/list/index.dspy
* /hermes-web-cli/services/{id} → services/id/index.dspy
* /hermes-web-cli/services/test?id={id} → services/test/index.dspy
* /hermes-web-cli/sessions (POST) → sessions/index.dspy
* /hermes-web-cli/sessions/messages?session_id={id} → sessions/messages/index.dspy
* /hermes-web-cli/settings → settings/index.dspy
* /hermes-web-cli/settings/reset → settings/reset/index.dspy
- Fixed UI styling to comply with bricks-framework (removed nested style objects)
- Updated URL references to use query parameters instead of path parameters for dynamic routes
- All files follow production-ready module development specifications
56 lines
1.7 KiB
Plaintext
56 lines
1.7 KiB
Plaintext
# 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/test?id={service_id}
|
|
|
|
import json
|
|
import os
|
|
from hermes_web_cli.init import get_service_by_id, test_service_connection
|
|
from urllib.parse import parse_qs
|
|
|
|
def main():
|
|
"""Main function to handle the service connection test API request with query parameter."""
|
|
try:
|
|
# Get service ID from query string
|
|
query_string = os.environ.get('QUERY_STRING', '')
|
|
if query_string:
|
|
query_params = parse_qs(query_string)
|
|
service_id = query_params.get('id', [None])[0]
|
|
else:
|
|
service_id = None
|
|
|
|
if not service_id:
|
|
return {
|
|
"status": "error",
|
|
"message": "Service ID is required (use ?id= parameter)",
|
|
"data": None
|
|
}
|
|
|
|
# Get service by ID
|
|
service = get_service_by_id(service_id)
|
|
if not service:
|
|
return {
|
|
"status": "error",
|
|
"message": "Service not found",
|
|
"data": None
|
|
}
|
|
|
|
# Test connection
|
|
is_connected, status_message = test_service_connection(service.get("service_url", ""))
|
|
|
|
return {
|
|
"status": "success",
|
|
"data": {
|
|
"is_connected": is_connected,
|
|
"status_message": status_message,
|
|
"service_id": service_id
|
|
}
|
|
}
|
|
except Exception as e:
|
|
return {
|
|
"status": "error",
|
|
"message": str(e),
|
|
"data": None
|
|
}
|
|
|
|
# Execute and return JSON response
|
|
result = main()
|
|
print(json.dumps(result, ensure_ascii=False)) |