Ashrafb commited on
Commit
8238e8a
·
verified ·
1 Parent(s): c855cea

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +34 -23
static/index.html CHANGED
@@ -1,7 +1,7 @@
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
4
- <title>Face Swapper App</title>
5
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css">
6
  <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet">
7
  <style>
@@ -264,38 +264,49 @@ h1 {
264
  reader.readAsDataURL(file);
265
  }
266
 
267
- async function swapFaces() {
268
- const form = document.getElementById('swapForm');
269
- const formData = new FormData(form);
 
270
 
271
- try {
272
- // Display loading spinner
273
- const loadingSpinner = document.getElementById('loadingSpinner');
274
- loadingSpinner.style.display = 'block';
275
 
276
- // Remove previous result image
277
- const resultContainer = document.getElementById('resultContainer');
278
- resultContainer.innerHTML = '';
279
 
280
- const response = await fetch('/swap_faces/', {
281
- method: 'POST',
282
- body: formData
283
- });
 
 
 
284
  const blob = await response.blob();
285
  const imageUrl = URL.createObjectURL(blob);
286
 
287
  // Display the result image
288
  resultContainer.innerHTML = `<img src="${imageUrl}" alt="Result Image" style="max-width: 100%;">`;
289
-
290
- // Hide loading spinner after result image is displayed
291
- loadingSpinner.style.display = 'none';
292
- } catch (error) {
293
- console.error('Error swapping faces:', error);
294
- // Hide loading spinner if there's an error
295
- const loadingSpinner = document.getElementById('loadingSpinner');
296
- loadingSpinner.style.display = 'none';
297
  }
 
 
 
 
 
 
 
 
298
  }
 
 
 
299
  </script>
300
  </body>
301
  </html>
 
1
  <!DOCTYPE html>
2
  <html>
3
  <head>
4
+
5
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.13.11/katex.min.css">
6
  <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@100&display=swap" rel="stylesheet">
7
  <style>
 
264
  reader.readAsDataURL(file);
265
  }
266
 
267
+
268
+ async function swapFaces() {
269
+ const form = document.getElementById('swapForm');
270
+ const formData = new FormData(form);
271
 
272
+ try {
273
+ // Display loading spinner
274
+ const loadingSpinner = document.getElementById('loadingSpinner');
275
+ loadingSpinner.style.display = 'block';
276
 
277
+ // Remove previous result image and error message
278
+ const resultContainer = document.getElementById('resultContainer');
279
+ resultContainer.innerHTML = '';
280
 
281
+ const response = await fetch('/swap_faces/', {
282
+ method: 'POST',
283
+ body: formData
284
+ });
285
+
286
+ // Check if response is ok
287
+ if (response.ok) {
288
  const blob = await response.blob();
289
  const imageUrl = URL.createObjectURL(blob);
290
 
291
  // Display the result image
292
  resultContainer.innerHTML = `<img src="${imageUrl}" alt="Result Image" style="max-width: 100%;">`;
293
+ } else {
294
+ // If response is not ok, display the error message
295
+ const errorMessage = await response.text();
296
+ resultContainer.innerText = errorMessage;
 
 
 
 
297
  }
298
+
299
+ // Hide loading spinner after result image or error message is displayed
300
+ loadingSpinner.style.display = 'none';
301
+ } catch (error) {
302
+ console.error('Error swapping faces:', error);
303
+ // Hide loading spinner if there's an error
304
+ const loadingSpinner = document.getElementById('loadingSpinner');
305
+ loadingSpinner.style.display = 'none';
306
  }
307
+ }
308
+
309
+
310
  </script>
311
  </body>
312
  </html>