Ashrafb commited on
Commit
eb260ff
·
verified ·
1 Parent(s): deae8ac

Create static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +55 -0
static/index.html ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Color Restoration</title>
7
+ </head>
8
+ <body>
9
+ <h1>Color Restoration</h1>
10
+ <form action="/upload/" method="post" enctype="multipart/form-data">
11
+ <input type="file" name="file" accept=".jpg, .jpeg, .png" required>
12
+ <button type="submit">Upload</button>
13
+ </form>
14
+ <hr>
15
+ <h2>Original Photo</h2>
16
+ <div id="original-image"></div>
17
+ <hr>
18
+ <h2>Colorized Photo</h2>
19
+ <div id="colorized-image"></div>
20
+ <hr>
21
+ <a id="download-link" href="#" download="colorized_image.jpg" style="display:none;">Download Colorized Image</a>
22
+
23
+ <script>
24
+ function displayOriginalImage(file) {
25
+ const reader = new FileReader();
26
+ reader.onload = function(e) {
27
+ const originalImageDiv = document.getElementById('original-image');
28
+ originalImageDiv.innerHTML = `<img src="${e.target.result}" alt="Original Image" width="400">`;
29
+ }
30
+ reader.readAsDataURL(file);
31
+ }
32
+
33
+ function displayColorizedImage(blob) {
34
+ const url = URL.createObjectURL(blob);
35
+ const colorizedImageDiv = document.getElementById('colorized-image');
36
+ colorizedImageDiv.innerHTML = `<img src="${url}" alt="Colorized Image" width="400">`;
37
+ const downloadLink = document.getElementById('download-link');
38
+ downloadLink.href = url;
39
+ downloadLink.style.display = 'block';
40
+ }
41
+
42
+ document.querySelector('form').addEventListener('submit', async function(e) {
43
+ e.preventDefault();
44
+ const formData = new FormData(this);
45
+ const response = await fetch('/upload/', {
46
+ method: 'POST',
47
+ body: formData
48
+ });
49
+ const blob = await response.blob();
50
+ displayOriginalImage(formData.get('file'));
51
+ displayColorizedImage(blob);
52
+ });
53
+ </script>
54
+ </body>
55
+ </html>