Spaces:
Sleeping
Sleeping
Delete index.html
Browse files- index.html +0 -169
index.html
DELETED
@@ -1,169 +0,0 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
4 |
-
<meta charset="UTF-8">
|
5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>API Client for Secure Decoder Plugin</title>
|
7 |
-
<style>
|
8 |
-
:root {
|
9 |
-
--primary-color: #3b82f6;
|
10 |
-
--primary-hover: #2563eb;
|
11 |
-
--border-color: #d1d5db;
|
12 |
-
--background-color: #f9fafb;
|
13 |
-
--text-color: #1f2937;
|
14 |
-
--error-color: #ef4444;
|
15 |
-
--success-color: #22c55e;
|
16 |
-
}
|
17 |
-
body {
|
18 |
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
19 |
-
line-height: 1.6;
|
20 |
-
max-width: 700px;
|
21 |
-
margin: 2rem auto;
|
22 |
-
padding: 0 1rem;
|
23 |
-
color: var(--text-color);
|
24 |
-
}
|
25 |
-
main {
|
26 |
-
display: flex;
|
27 |
-
flex-direction: column;
|
28 |
-
gap: 1.5rem;
|
29 |
-
border: 1px solid var(--border-color);
|
30 |
-
padding: 1.5rem;
|
31 |
-
border-radius: 0.5rem;
|
32 |
-
background-color: white;
|
33 |
-
}
|
34 |
-
h1 {
|
35 |
-
color: #111827;
|
36 |
-
text-align: center;
|
37 |
-
}
|
38 |
-
section {
|
39 |
-
display: flex;
|
40 |
-
flex-direction: column;
|
41 |
-
gap: 0.5rem;
|
42 |
-
}
|
43 |
-
label {
|
44 |
-
font-weight: 600;
|
45 |
-
}
|
46 |
-
input[type="text"], input[type="file"] {
|
47 |
-
font-size: 1rem;
|
48 |
-
padding: 0.5rem 0.75rem;
|
49 |
-
border: 1px solid var(--border-color);
|
50 |
-
border-radius: 0.375rem;
|
51 |
-
}
|
52 |
-
button {
|
53 |
-
font-size: 1rem;
|
54 |
-
font-weight: 600;
|
55 |
-
padding: 0.75rem 1rem;
|
56 |
-
cursor: pointer;
|
57 |
-
border: none;
|
58 |
-
border-radius: 0.375rem;
|
59 |
-
background-color: var(--primary-color);
|
60 |
-
color: white;
|
61 |
-
transition: background-color 0.2s;
|
62 |
-
}
|
63 |
-
button:hover:not(:disabled) {
|
64 |
-
background-color: var(--primary-hover);
|
65 |
-
}
|
66 |
-
button:disabled {
|
67 |
-
background-color: #9ca3af;
|
68 |
-
cursor: not-allowed;
|
69 |
-
}
|
70 |
-
#result-output {
|
71 |
-
background: var(--background-color);
|
72 |
-
padding: 1rem;
|
73 |
-
border-radius: 5px;
|
74 |
-
white-space: pre-wrap;
|
75 |
-
word-wrap: break-word;
|
76 |
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
77 |
-
min-height: 60px;
|
78 |
-
border: 1px solid var(--border-color);
|
79 |
-
}
|
80 |
-
.result-error { color: var(--error-color); }
|
81 |
-
.result-success { color: var(--success-color); }
|
82 |
-
</style>
|
83 |
-
</head>
|
84 |
-
<body>
|
85 |
-
<h1>Secure Decoder Plugin Client</h1>
|
86 |
-
<p style="text-align: center;">Use this page to test your deployed Hugging Face API. It sends an encrypted image to your secure server endpoint for decoding.</p>
|
87 |
-
|
88 |
-
<main>
|
89 |
-
<section>
|
90 |
-
<label for="api-url">1. Your Deployed API Endpoint URL:</label>
|
91 |
-
<input type="text" id="api-url" placeholder="https://broadfield-dev-keylock-rsa-js.static.hf.space/api/decode">
|
92 |
-
</section>
|
93 |
-
|
94 |
-
<section>
|
95 |
-
<label for="image-upload">2. Upload Image (Encrypted with Plugin's Public Key):</label>
|
96 |
-
<input type="file" id="image-upload" accept="image/png">
|
97 |
-
</section>
|
98 |
-
|
99 |
-
<button id="submit-button">Send to Plugin for Decoding</button>
|
100 |
-
|
101 |
-
<section>
|
102 |
-
<h3>Result from Server:</h3>
|
103 |
-
<div id="result-output">Awaiting input...</div>
|
104 |
-
</section>
|
105 |
-
</main>
|
106 |
-
|
107 |
-
<script>
|
108 |
-
const apiUrlInput = document.getElementById('api-url');
|
109 |
-
const imageInput = document.getElementById('image-upload');
|
110 |
-
const submitButton = document.getElementById('submit-button');
|
111 |
-
const resultOutput = document.getElementById('result-output');
|
112 |
-
|
113 |
-
submitButton.addEventListener('click', async () => {
|
114 |
-
const file = imageInput.files[0];
|
115 |
-
const apiUrl = apiUrlInput.value.trim();
|
116 |
-
|
117 |
-
// --- Input Validation ---
|
118 |
-
if (!apiUrl) {
|
119 |
-
resultOutput.textContent = 'Error: Please provide the API endpoint URL.';
|
120 |
-
resultOutput.className = 'result-error';
|
121 |
-
return;
|
122 |
-
}
|
123 |
-
if (!file) {
|
124 |
-
resultOutput.textContent = 'Error: Please select an image file to upload.';
|
125 |
-
resultOutput.className = 'result-error';
|
126 |
-
return;
|
127 |
-
}
|
128 |
-
|
129 |
-
// --- UI Feedback for Loading State ---
|
130 |
-
resultOutput.textContent = 'Uploading and decoding...';
|
131 |
-
resultOutput.className = '';
|
132 |
-
submitButton.disabled = true;
|
133 |
-
submitButton.textContent = 'Processing...';
|
134 |
-
|
135 |
-
// --- Prepare and Send the Request ---
|
136 |
-
const formData = new FormData();
|
137 |
-
formData.append('authImage', file); // 'authImage' must match the server's expected field name
|
138 |
-
|
139 |
-
try {
|
140 |
-
const response = await fetch(apiUrl, {
|
141 |
-
method: 'POST',
|
142 |
-
body: formData,
|
143 |
-
});
|
144 |
-
|
145 |
-
const result = await response.json();
|
146 |
-
|
147 |
-
if (!response.ok) {
|
148 |
-
// If the server returns an error (like 400 or 500), throw it
|
149 |
-
throw new Error(result.error || `Server responded with status ${response.status}`);
|
150 |
-
}
|
151 |
-
|
152 |
-
// --- Handle Success ---
|
153 |
-
resultOutput.className = 'result-success';
|
154 |
-
resultOutput.textContent = `✅ Success! Decoded Data:\n\n${JSON.stringify(result.data, null, 2)}`;
|
155 |
-
|
156 |
-
} catch (error) {
|
157 |
-
// --- Handle Failure (Network error or server error) ---
|
158 |
-
resultOutput.className = 'result-error';
|
159 |
-
resultOutput.textContent = `❌ API Request Failed:\n\n${error.message}`;
|
160 |
-
console.error('API Error:', error);
|
161 |
-
} finally {
|
162 |
-
// --- Reset UI ---
|
163 |
-
submitButton.disabled = false;
|
164 |
-
submitButton.textContent = 'Send to Plugin for Decoding';
|
165 |
-
}
|
166 |
-
});
|
167 |
-
</script>
|
168 |
-
</body>
|
169 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|