Hadiil commited on
Commit
853e563
·
verified ·
1 Parent(s): f8019ae

Upload index.html

Browse files
Files changed (1) hide show
  1. static/index.html +103 -0
static/index.html ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>AI-Powered Web Application</title>
7
+ <style>
8
+ body {
9
+ font-family: Arial, sans-serif;
10
+ margin: 20px;
11
+ }
12
+ .container {
13
+ max-width: 600px;
14
+ margin: 0 auto;
15
+ }
16
+ h1 {
17
+ text-align: center;
18
+ }
19
+ form {
20
+ margin-bottom: 20px;
21
+ }
22
+ input[type="file"], input[type="text"], button {
23
+ display: block;
24
+ margin: 10px 0;
25
+ padding: 10px;
26
+ width: 100%;
27
+ }
28
+ .result {
29
+ margin-top: 20px;
30
+ padding: 10px;
31
+ background-color: #f4f4f4;
32
+ border: 1px solid #ddd;
33
+ }
34
+ </style>
35
+ </head>
36
+ <body>
37
+ <div class="container">
38
+ <h1>AI-Powered Web Application</h1>
39
+
40
+ <!-- Document Summarization -->
41
+ <h2>Document Summarization</h2>
42
+ <form id="summarizeForm">
43
+ <input type="file" id="document" name="document" accept=".pdf,.docx">
44
+ <button type="submit">Summarize</button>
45
+ </form>
46
+ <div class="result" id="summaryResult"></div>
47
+
48
+ <!-- Image Captioning -->
49
+ <h2>Image Captioning</h2>
50
+ <form id="captionForm">
51
+ <input type="file" id="image" name="image" accept=".jpg,.jpeg,.png">
52
+ <button type="submit">Generate Caption</button>
53
+ </form>
54
+ <div class="result" id="captionResult"></div>
55
+
56
+ <!-- Text-Based Question Answering -->
57
+ <h2>Text-Based Question Answering</h2>
58
+ <form id="qaForm">
59
+ <input type="file" id="qaDocument" name="document" accept=".pdf,.docx">
60
+ <input type="text" id="question" name="question" placeholder="Enter your question">
61
+ <button type="submit">Ask</button>
62
+ </form>
63
+ <div class="result" id="qaResult"></div>
64
+
65
+ <!-- Visual Question Answering -->
66
+ <h2>Visual Question Answering</h2>
67
+ <form id="vqaForm">
68
+ <input type="file" id="vqaImage" name="image" accept=".jpg,.jpeg,.png">
69
+ <input type="text" id="vqaQuestion" name="question" placeholder="Enter your question">
70
+ <button type="submit">Ask</button>
71
+ </form>
72
+ <div class="result" id="vqaResult"></div>
73
+ </div>
74
+
75
+ <script>
76
+ // Function to handle form submissions
77
+ async function handleFormSubmit(event, endpoint, resultId) {
78
+ event.preventDefault();
79
+ const formData = new FormData();
80
+ const fileInput = event.target.querySelector('input[type="file"]');
81
+ const textInput = event.target.querySelector('input[type="text"]');
82
+
83
+ formData.append("file", fileInput.files[0]);
84
+ if (textInput) {
85
+ formData.append("question", textInput.value);
86
+ }
87
+
88
+ const response = await fetch(endpoint, {
89
+ method: "POST",
90
+ body: formData
91
+ });
92
+ const result = await response.json();
93
+ document.getElementById(resultId).innerText = JSON.stringify(result, null, 2);
94
+ }
95
+
96
+ // Attach event listeners to forms
97
+ document.getElementById("summarizeForm").onsubmit = (e) => handleFormSubmit(e, "/summarize", "summaryResult");
98
+ document.getElementById("captionForm").onsubmit = (e) => handleFormSubmit(e, "/caption", "captionResult");
99
+ document.getElementById("qaForm").onsubmit = (e) => handleFormSubmit(e, "/answer", "qaResult");
100
+ document.getElementById("vqaForm").onsubmit = (e) => handleFormSubmit(e, "/vqa", "vqaResult");
101
+ </script>
102
+ </body>
103
+ </html>