Spaces:
Sleeping
Sleeping
Download test_client.html from Vignesh5656/transformation-api: direct link, hf CLI and curl.
- Browser
- Download file 8.7 kB
-
https://huggingface.co/spaces/Vignesh5656/transformation-api/resolve/main/test_client.html
- Command line
-
hf download hf://spaces/Vignesh5656/transformation-api/test_client.html
-
curl -L -o test_client.html https://huggingface.co/spaces/Vignesh5656/transformation-api/resolve/main/test_client.html
8.7 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Processing Simulator WebSocket Client</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| max-width: 800px; | |
| margin: 0 auto; | |
| padding: 20px; | |
| background-color: #f5f5f5; | |
| } | |
| .container { | |
| background-color: white; | |
| padding: 20px; | |
| border-radius: 8px; | |
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | |
| } | |
| .form-group { | |
| margin-bottom: 15px; | |
| } | |
| label { | |
| display: block; | |
| margin-bottom: 5px; | |
| font-weight: bold; | |
| } | |
| input[type="text"] { | |
| width: 100%; | |
| padding: 8px; | |
| border: 1px solid #ddd; | |
| border-radius: 4px; | |
| box-sizing: border-box; | |
| } | |
| button { | |
| background-color: #007bff; | |
| color: white; | |
| padding: 10px 20px; | |
| border: none; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| margin-right: 10px; | |
| } | |
| button:hover { | |
| background-color: #0056b3; | |
| } | |
| button:disabled { | |
| background-color: #6c757d; | |
| cursor: not-allowed; | |
| } | |
| .status { | |
| margin: 10px 0; | |
| padding: 10px; | |
| border-radius: 4px; | |
| } | |
| .status.connected { | |
| background-color: #d4edda; | |
| color: #155724; | |
| border: 1px solid #c3e6cb; | |
| } | |
| .status.disconnected { | |
| background-color: #f8d7da; | |
| color: #721c24; | |
| border: 1px solid #f5c6cb; | |
| } | |
| .messages { | |
| border: 1px solid #ddd; | |
| height: 400px; | |
| overflow-y: scroll; | |
| padding: 10px; | |
| background-color: #f8f9fa; | |
| border-radius: 4px; | |
| margin-top: 15px; | |
| } | |
| .message { | |
| margin-bottom: 10px; | |
| padding: 8px; | |
| border-radius: 4px; | |
| border-left: 4px solid #007bff; | |
| background-color: white; | |
| } | |
| .message.progress { | |
| border-left-color: #ffc107; | |
| } | |
| .message.completion { | |
| border-left-color: #28a745; | |
| background-color: #f8fff9; | |
| } | |
| .message.error { | |
| border-left-color: #dc3545; | |
| background-color: #fff5f5; | |
| } | |
| .timestamp { | |
| font-size: 0.8em; | |
| color: #6c757d; | |
| } | |
| pre { | |
| background-color: #f1f3f4; | |
| padding: 10px; | |
| border-radius: 4px; | |
| overflow-x: auto; | |
| font-size: 0.9em; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>Processing Simulator WebSocket Client</h1> | |
| <div class="form-group"> | |
| <label for="wsUrl">WebSocket URL:</label> | |
| <input type="text" id="wsUrl" value="ws://10.170.2.156:8000/ws"> | |
| </div> | |
| <div class="form-group"> | |
| <label for="foldername">Folder Name:</label> | |
| <input type="text" id="foldername" value="sample-folder" placeholder="Enter folder name"> | |
| </div> | |
| <div class="form-group"> | |
| <label for="environment">Environment:</label> | |
| <input type="text" id="environment" value="production" placeholder="Enter environment (e.g., dev, staging, production)"> | |
| </div> | |
| <div> | |
| <button id="connectBtn" onclick="connect()">Connect</button> | |
| <button id="disconnectBtn" onclick="disconnect()" disabled>Disconnect</button> | |
| <button id="sendBtn" onclick="sendRequest()" disabled>Send Processing Request</button> | |
| <button onclick="clearMessages()">Clear Messages</button> | |
| </div> | |
| <div id="status" class="status disconnected">Disconnected</div> | |
| <div id="messages" class="messages"></div> | |
| </div> | |
| <script> | |
| let ws = null; | |
| function connect() { | |
| const wsUrl = document.getElementById('wsUrl').value; | |
| try { | |
| ws = new WebSocket(wsUrl); | |
| ws.onopen = function(event) { | |
| updateStatus('Connected', 'connected'); | |
| document.getElementById('connectBtn').disabled = true; | |
| document.getElementById('disconnectBtn').disabled = false; | |
| document.getElementById('sendBtn').disabled = false; | |
| addMessage('Connected to WebSocket server', 'info'); | |
| }; | |
| ws.onmessage = function(event) { | |
| try { | |
| const data = JSON.parse(event.data); | |
| displayMessage(data); | |
| } catch (e) { | |
| addMessage(`Raw message: ${event.data}`, 'info'); | |
| } | |
| }; | |
| ws.onclose = function(event) { | |
| updateStatus('Disconnected', 'disconnected'); | |
| document.getElementById('connectBtn').disabled = false; | |
| document.getElementById('disconnectBtn').disabled = true; | |
| document.getElementById('sendBtn').disabled = true; | |
| addMessage('Disconnected from WebSocket server', 'info'); | |
| }; | |
| ws.onerror = function(error) { | |
| addMessage(`WebSocket error: ${error}`, 'error'); | |
| }; | |
| } catch (error) { | |
| addMessage(`Connection error: ${error}`, 'error'); | |
| } | |
| } | |
| function disconnect() { | |
| if (ws) { | |
| ws.close(); | |
| ws = null; | |
| } | |
| } | |
| function sendRequest() { | |
| if (ws && ws.readyState === WebSocket.OPEN) { | |
| const foldername = document.getElementById('foldername').value; | |
| const environment = document.getElementById('environment').value; | |
| if (!foldername || !environment) { | |
| addMessage('Please fill in both folder name and environment', 'error'); | |
| return; | |
| } | |
| const request = { | |
| foldername: foldername, | |
| environment: environment | |
| }; | |
| ws.send(JSON.stringify(request)); | |
| addMessage(`Sent processing request: ${JSON.stringify(request)}`, 'info'); | |
| } else { | |
| addMessage('WebSocket is not connected', 'error'); | |
| } | |
| } | |
| function displayMessage(data) { | |
| let messageType = 'info'; | |
| let message = ''; | |
| if (data.error) { | |
| messageType = 'error'; | |
| message = `Error: ${data.error}`; | |
| } else if (data.type === 'progress') { | |
| messageType = 'progress'; | |
| message = `[${data.progress_percentage}%] ${data.message}`; | |
| } else if (data.type === 'completion') { | |
| messageType = 'completion'; | |
| message = `${data.message}\n\nFinal Stats:\n${JSON.stringify(data.stats, null, 2)}`; | |
| } else { | |
| message = data.message || JSON.stringify(data); | |
| } | |
| addMessage(message, messageType, data.timestamp); | |
| } | |
| function addMessage(text, type = 'info', timestamp = null) { | |
| const messagesDiv = document.getElementById('messages'); | |
| const messageDiv = document.createElement('div'); | |
| messageDiv.className = `message ${type}`; | |
| const timeStr = timestamp ? new Date(timestamp).toLocaleTimeString() : new Date().toLocaleTimeString(); | |
| messageDiv.innerHTML = ` | |
| <div>${text}</div> | |
| <div class="timestamp">${timeStr}</div> | |
| `; | |
| messagesDiv.appendChild(messageDiv); | |
| messagesDiv.scrollTop = messagesDiv.scrollHeight; | |
| } | |
| function updateStatus(text, className) { | |
| const statusDiv = document.getElementById('status'); | |
| statusDiv.textContent = text; | |
| statusDiv.className = `status ${className}`; | |
| } | |
| function clearMessages() { | |
| document.getElementById('messages').innerHTML = ''; | |
| } | |
| </script> | |
| </body> | |
| </html> |