Hadiil commited on
Commit
55adf2c
·
verified ·
1 Parent(s): aeba6c0

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +107 -80
static/index.html CHANGED
@@ -3,114 +3,141 @@
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"], textarea, 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
- <p>Or</p>
45
- <textarea id="manualText" name="text" placeholder="Enter text manually"></textarea>
46
- <button type="submit">Summarize</button>
47
- </form>
48
- <div class="result" id="summaryResult"></div>
49
 
50
- <!-- Text-Based Question Answering -->
51
- <h2>Text-Based Question Answering</h2>
52
- <form id="qaForm">
53
- <input type="file" id="qaDocument" name="document" accept=".pdf,.docx">
54
- <p>Or</p>
55
- <textarea id="qaText" name="text" placeholder="Enter text manually"></textarea>
56
- <input type="text" id="question" name="question" placeholder="Enter your question">
57
- <button type="submit">Ask</button>
58
- </form>
59
- <div class="result" id="qaResult"></div>
60
 
61
- <!-- Image Captioning -->
62
- <h2>Image Captioning</h2>
63
- <form id="captionForm">
64
- <input type="file" id="image" name="image" accept=".jpg,.jpeg,.png">
65
- <button type="submit">Generate Caption</button>
66
- </form>
67
- <div class="result" id="captionResult"></div>
 
68
 
69
- <!-- Visual Question Answering -->
70
- <h2>Visual Question Answering</h2>
71
- <form id="vqaForm">
72
- <input type="file" id="vqaImage" name="image" accept=".jpg,.jpeg,.png">
73
- <input type="text" id="vqaQuestion" name="question" placeholder="Enter your question">
74
- <button type="submit">Ask</button>
75
- </form>
76
- <div class="result" id="vqaResult"></div>
77
- </div>
 
 
 
 
 
 
 
 
78
 
79
  <script>
80
- // Function to handle form submissions
81
- async function handleFormSubmit(event, endpoint, resultId) {
82
- event.preventDefault();
83
- const formData = new FormData();
84
- const fileInput = event.target.querySelector('input[type="file"]');
85
- const textInput = event.target.querySelector('textarea');
86
- const questionInput = event.target.querySelector('input[type="text"]');
87
 
88
- if (fileInput.files[0]) {
89
- formData.append("file", fileInput.files[0]);
90
- } else if (textInput && textInput.value) {
91
- formData.append("text", textInput.value);
92
- } else {
93
- alert("Please upload a file or enter text manually.");
94
- return;
95
- }
96
 
97
- if (questionInput) {
98
- formData.append("question", questionInput.value);
99
- }
 
 
100
 
101
- const response = await fetch(endpoint, {
102
- method: "POST",
103
- body: formData
104
- });
105
- const result = await response.json();
106
- document.getElementById(resultId).innerText = JSON.stringify(result, null, 2);
107
- }
108
 
109
- // Attach event listeners to forms
110
- document.getElementById("summarizeForm").onsubmit = (e) => handleFormSubmit(e, "/summarize", "summaryResult");
111
- document.getElementById("qaForm").onsubmit = (e) => handleFormSubmit(e, "/answer", "qaResult");
112
- document.getElementById("captionForm").onsubmit = (e) => handleFormSubmit(e, "/caption", "captionResult");
113
- document.getElementById("vqaForm").onsubmit = (e) => handleFormSubmit(e, "/vqa", "vqaResult");
 
114
  </script>
115
  </body>
116
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>AI Web Application</title>
7
  <style>
8
  body {
9
  font-family: Arial, sans-serif;
10
  margin: 20px;
11
+ padding: 0;
12
+ background-color: #f4f4f9;
13
+ color: #333;
 
14
  }
15
  h1 {
16
  text-align: center;
17
+ color: #444;
18
+ }
19
+ h2 {
20
+ color: #555;
21
+ border-bottom: 2px solid #ddd;
22
+ padding-bottom: 5px;
23
  }
24
  form {
25
+ background: #fff;
26
+ padding: 20px;
27
+ border-radius: 8px;
28
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
29
  margin-bottom: 20px;
30
  }
31
+ input[type="file"], textarea, input[type="text"] {
 
 
 
32
  width: 100%;
 
 
 
33
  padding: 10px;
34
+ margin: 10px 0;
35
  border: 1px solid #ddd;
36
+ border-radius: 4px;
37
+ font-size: 16px;
38
+ }
39
+ button {
40
+ background-color: #007bff;
41
+ color: white;
42
+ border: none;
43
+ padding: 10px 20px;
44
+ border-radius: 4px;
45
+ cursor: pointer;
46
+ font-size: 16px;
47
+ }
48
+ button:hover {
49
+ background-color: #0056b3;
50
+ }
51
+ .result {
52
+ background: #e9ecef;
53
+ padding: 15px;
54
+ border-radius: 4px;
55
+ margin-top: 10px;
56
+ font-family: monospace;
57
  }
58
  </style>
59
  </head>
60
  <body>
61
+ <h1>AI Web Application</h1>
62
+
63
+ <!-- Summarization -->
64
+ <h2>Summarization</h2>
65
+ <form id="summarizeForm">
66
+ <input type="file" name="file" accept=".pdf,.docx">
67
+ <textarea name="text" placeholder="Or enter text manually"></textarea>
68
+ <button type="button" onclick="submitForm('/summarize', 'summarizeForm', 'summarizeResult')">Summarize</button>
69
+ </form>
70
+ <div id="summarizeResult" class="result"></div>
71
 
72
+ <!-- Image Captioning -->
73
+ <h2>Image Captioning</h2>
74
+ <form id="captionForm">
75
+ <input type="file" name="file" accept="image/*">
76
+ <button type="button" onclick="submitForm('/caption', 'captionForm', 'captionResult')">Generate Caption</button>
77
+ </form>
78
+ <div id="captionResult" class="result"></div>
 
 
79
 
80
+ <!-- Question Answering -->
81
+ <h2>Question Answering</h2>
82
+ <form id="answerForm">
83
+ <input type="file" name="file" accept=".pdf,.docx">
84
+ <textarea name="text" placeholder="Or enter text manually"></textarea>
85
+ <input type="text" name="question" placeholder="Enter your question">
86
+ <button type="button" onclick="submitForm('/answer', 'answerForm', 'answerResult')">Answer</button>
87
+ </form>
88
+ <div id="answerResult" class="result"></div>
 
89
 
90
+ <!-- Visual Question Answering -->
91
+ <h2>Visual Question Answering</h2>
92
+ <form id="vqaForm">
93
+ <input type="file" name="file" accept="image/*">
94
+ <input type="text" name="question" placeholder="Enter your question">
95
+ <button type="button" onclick="submitForm('/vqa', 'vqaForm', 'vqaResult')">Answer</button>
96
+ </form>
97
+ <div id="vqaResult" class="result"></div>
98
 
99
+ <!-- Data Visualization -->
100
+ <h2>Data Visualization</h2>
101
+ <form id="visualizeForm">
102
+ <input type="file" name="file" accept=".xlsx,.xls">
103
+ <input type="text" name="request" placeholder="Enter visualization request (e.g., bar, line)">
104
+ <button type="button" onclick="submitForm('/visualize', 'visualizeForm', 'visualizeResult')">Generate Code</button>
105
+ </form>
106
+ <div id="visualizeResult" class="result"></div>
107
+
108
+ <!-- Document Translation -->
109
+ <h2>Document Translation</h2>
110
+ <form id="translateForm">
111
+ <input type="file" name="file" accept=".pdf,.docx">
112
+ <input type="text" name="target_language" placeholder="Enter target language (e.g., fr, es)">
113
+ <button type="button" onclick="submitForm('/translate', 'translateForm', 'translateResult')">Translate</button>
114
+ </form>
115
+ <div id="translateResult" class="result"></div>
116
 
117
  <script>
118
+ async function submitForm(endpoint, formId, resultId) {
119
+ const form = document.getElementById(formId);
120
+ const formData = new FormData(form);
121
+ const resultDiv = document.getElementById(resultId);
 
 
 
122
 
123
+ resultDiv.innerHTML = "Processing...";
 
 
 
 
 
 
 
124
 
125
+ try {
126
+ const response = await fetch(endpoint, {
127
+ method: 'POST',
128
+ body: formData
129
+ });
130
 
131
+ if (!response.ok) {
132
+ throw new Error(`HTTP error! Status: ${response.status}`);
133
+ }
 
 
 
 
134
 
135
+ const data = await response.json();
136
+ resultDiv.innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`;
137
+ } catch (error) {
138
+ resultDiv.innerHTML = `Error: ${error.message}`;
139
+ }
140
+ }
141
  </script>
142
  </body>
143
  </html>