Spaces:
Runtime error
Runtime error
File size: 10,032 Bytes
9d79680 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AJ API - Test Interface</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}
.header p {
font-size: 1.1em;
opacity: 0.9;
}
.content {
padding: 30px;
}
.input-group {
margin-bottom: 20px;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #333;
}
.input-group input {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 1em;
transition: border-color 0.3s;
}
.input-group input:focus {
outline: none;
border-color: #667eea;
}
.input-group textarea {
width: 100%;
padding: 12px;
border: 2px solid #e0e0e0;
border-radius: 8px;
font-size: 1em;
min-height: 100px;
resize: vertical;
font-family: inherit;
transition: border-color 0.3s;
}
.input-group textarea:focus {
outline: none;
border-color: #667eea;
}
.btn {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 15px 40px;
border: none;
border-radius: 8px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
width: 100%;
}
.btn:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}
.btn:active {
transform: translateY(0);
}
.btn:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.response {
margin-top: 20px;
padding: 20px;
background: #f5f5f5;
border-radius: 8px;
border-left: 4px solid #667eea;
display: none;
}
.response.show {
display: block;
}
.response h3 {
margin-bottom: 10px;
color: #333;
}
.response pre {
background: white;
padding: 15px;
border-radius: 5px;
overflow-x: auto;
white-space: pre-wrap;
word-wrap: break-word;
}
.loading {
text-align: center;
padding: 20px;
display: none;
}
.loading.show {
display: block;
}
.spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 1s linear infinite;
margin: 0 auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.endpoints {
margin-top: 30px;
padding: 20px;
background: #f9f9f9;
border-radius: 8px;
}
.endpoints h3 {
margin-bottom: 15px;
color: #333;
}
.endpoint {
margin-bottom: 10px;
padding: 10px;
background: white;
border-radius: 5px;
font-family: monospace;
}
.method {
display: inline-block;
padding: 3px 8px;
border-radius: 4px;
font-weight: 600;
margin-right: 10px;
}
.method.get {
background: #4caf50;
color: white;
}
.method.post {
background: #2196f3;
color: white;
}
.footer {
background: #f5f5f5;
padding: 20px;
text-align: center;
color: #666;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🤖 AJ API</h1>
<p>Test Your Deployed API</p>
<p style="font-size: 0.9em; margin-top: 10px;">Created by AJ STUDIOZ</p>
</div>
<div class="content">
<div class="input-group">
<label for="apiUrl">API URL</label>
<input type="text" id="apiUrl" placeholder="https://your-api-url.com" value="">
</div>
<div class="input-group">
<label for="message">Your Message</label>
<textarea id="message" placeholder="Type your message here...">Hello AJ, who are you?</textarea>
</div>
<button class="btn" id="sendBtn" onclick="sendMessage()">Send Message</button>
<div class="loading" id="loading">
<div class="spinner"></div>
<p style="margin-top: 10px;">Waiting for response...</p>
</div>
<div class="response" id="response">
<h3>Response:</h3>
<pre id="responseText"></pre>
</div>
<div class="endpoints">
<h3>Available Endpoints:</h3>
<div class="endpoint">
<span class="method get">GET</span>
<code>/health</code> - Health check
</div>
<div class="endpoint">
<span class="method get">GET</span>
<code>/api/info</code> - Model information
</div>
<div class="endpoint">
<span class="method post">POST</span>
<code>/api/chat</code> - Chat with AJ
</div>
<div class="endpoint">
<span class="method get">GET</span>
<code>/</code> - API homepage
</div>
</div>
</div>
<div class="footer">
<p><strong>AJ API</strong> - Created by AJ STUDIOZ</p>
<p style="margin-top: 5px;">🌐 <a href="https://ajstudioz.co.in" target="_blank">ajstudioz.co.in</a></p>
</div>
</div>
<script>
// Auto-detect API URL if running locally
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
document.getElementById('apiUrl').value = 'http://localhost:5000';
}
async function sendMessage() {
const apiUrl = document.getElementById('apiUrl').value.trim();
const message = document.getElementById('message').value.trim();
if (!apiUrl) {
alert('Please enter your API URL');
return;
}
if (!message) {
alert('Please enter a message');
return;
}
const sendBtn = document.getElementById('sendBtn');
const loading = document.getElementById('loading');
const response = document.getElementById('response');
const responseText = document.getElementById('responseText');
// Show loading
sendBtn.disabled = true;
loading.classList.add('show');
response.classList.remove('show');
try {
const res = await fetch(`${apiUrl}/api/chat`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: message })
});
const data = await res.json();
// Show response
loading.classList.remove('show');
response.classList.add('show');
responseText.textContent = JSON.stringify(data, null, 2);
} catch (error) {
loading.classList.remove('show');
response.classList.add('show');
responseText.textContent = `Error: ${error.message}\n\nMake sure:\n1. API URL is correct\n2. API is running\n3. CORS is enabled`;
} finally {
sendBtn.disabled = false;
}
}
// Allow Enter key to send (Ctrl+Enter for newline in textarea)
document.getElementById('message').addEventListener('keydown', function(e) {
if (e.key === 'Enter' && e.ctrlKey) {
sendMessage();
}
});
</script>
</body>
</html>
|