Spaces:
Running
Running
Download api.html from AFKKK3/tuwaiq-codehub-connect: direct link, hf CLI and curl.
- Browser
- Download file 5.72 kB
-
https://huggingface.co/spaces/AFKKK3/tuwaiq-codehub-connect/resolve/main/api.html
- Command line
-
hf download hf://spaces/AFKKK3/tuwaiq-codehub-connect/api.html
-
curl -L -o api.html https://huggingface.co/spaces/AFKKK3/tuwaiq-codehub-connect/resolve/main/api.html
5.72 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Tuwaiq CodeHub API</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| </head> | |
| <body class="bg-gray-900 text-gray-100 min-h-screen"> | |
| <div class="container mx-auto px-4 py-12"> | |
| <div class="text-center mb-12"> | |
| <h1 class="text-4xl font-bold mb-2">Tuwaiq CodeHub API</h1> | |
| <p class="text-xl text-gray-400">Backend service for the student code sharing platform</p> | |
| </div> | |
| <div class="bg-gray-800 rounded-lg shadow-lg p-6 mb-8"> | |
| <h2 class="text-2xl font-bold mb-4 text-purple-400">API Endpoints</h2> | |
| <div class="space-y-6"> | |
| <!-- Projects API --> | |
| <div class="bg-gray-700 rounded-lg p-4"> | |
| <div class="flex items-center mb-2"> | |
| <span class="bg-green-500 text-xs px-2 py-1 rounded mr-2">GET</span> | |
| <code class="text-purple-300">/api/projects</code> | |
| </div> | |
| <p class="text-gray-300 mb-3">Get all student projects</p> | |
| <button onclick="testEndpoint('/api/projects')" class="bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded text-sm"> | |
| Test Endpoint | |
| </button> | |
| </div> | |
| <!-- Code Snippets API --> | |
| <div class="bg-gray-700 rounded-lg p-4"> | |
| <div class="flex items-center mb-2"> | |
| <span class="bg-blue-500 text-xs px-2 py-1 rounded mr-2">POST</span> | |
| <code class="text-purple-300">/api/snippets</code> | |
| </div> | |
| <p class="text-gray-300 mb-3">Submit a new code snippet</p> | |
| <button onclick="testEndpoint('/api/snippets')" class="bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded text-sm"> | |
| Test Endpoint | |
| </button> | |
| </div> | |
| <!-- Chat API --> | |
| <div class="bg-gray-700 rounded-lg p-4"> | |
| <div class="flex items-center mb-2"> | |
| <span class="bg-yellow-500 text-xs px-2 py-1 rounded mr-2">GET</span> | |
| <code class="text-purple-300">/api/chat</code> | |
| </div> | |
| <p class="text-gray-300 mb-3">Get chat messages</p> | |
| <button onclick="testEndpoint('/api/chat')" class="bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded text-sm"> | |
| Test Endpoint | |
| </button> | |
| </div> | |
| <!-- Users API --> | |
| <div class="bg-gray-700 rounded-lg p-4"> | |
| <div class="flex items-center mb-2"> | |
| <span class="bg-red-500 text-xs px-2 py-1 rounded mr-2">GET</span> | |
| <code class="text-purple-300">/api/users</code> | |
| </div> | |
| <p class="text-gray-300 mb-3">Get user information</p> | |
| <button onclick="testEndpoint('/api/users')" class="bg-purple-600 hover:bg-purple-700 text-white px-3 py-1 rounded text-sm"> | |
| Test Endpoint | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="bg-gray-800 rounded-lg shadow-lg p-6"> | |
| <h2 class="text-2xl font-bold mb-4 text-purple-400">API Response</h2> | |
| <div id="apiResponse" class="bg-gray-900 rounded-lg p-4 min-h-32"> | |
| <p class="text-gray-500">Response will appear here...</p> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| feather.replace(); | |
| async function testEndpoint(endpoint) { | |
| const responseDiv = document.getElementById('apiResponse'); | |
| responseDiv.innerHTML = '<p class="text-purple-400">Loading...</p>'; | |
| try { | |
| // Simulate API call with mock data | |
| const mockData = { | |
| '/api/projects': { | |
| status: 'success', | |
| data: [ | |
| { id: 1, title: 'Sentiment Analysis Tool', author: 'Ali R.' }, | |
| { id: 2, title: 'E-commerce Platform', author: 'Sarah K.' } | |
| ] | |
| }, | |
| '/api/snippets': { | |
| status: 'success', | |
| message: 'Code snippet submitted successfully' | |
| }, | |
| '/api/chat': { | |
| status: 'success', | |
| messages: [ | |
| { id: 1, user: 'Moha_Dev', text: 'Check out this awesome resource...' } | |
| ] | |
| }, | |
| '/api/users': { | |
| status: 'success', | |
| user: { id: 1, name: 'Ahmed Al-Mansour', role: 'Student' } | |
| } | |
| }; | |
| // Simulate network delay | |
| await new Promise(resolve => setTimeout(resolve, 800)); | |
| const response = mockData[endpoint] || { status: 'error', message: 'Endpoint not found' }; | |
| responseDiv.innerHTML = `<pre class="text-green-400">${JSON.stringify(response, null, 2)}</pre>`; | |
| } catch (error) { | |
| responseDiv.innerHTML = `<p class="text-red-400">Error: ${error.message}</p>`; | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |