Spaces:
Runtime error
Runtime error
Update static/index.html
Browse files- 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
|
| 7 |
<style>
|
| 8 |
body {
|
| 9 |
font-family: Arial, sans-serif;
|
| 10 |
margin: 20px;
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 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"]
|
| 23 |
-
display: block;
|
| 24 |
-
margin: 10px 0;
|
| 25 |
-
padding: 10px;
|
| 26 |
width: 100%;
|
| 27 |
-
}
|
| 28 |
-
.result {
|
| 29 |
-
margin-top: 20px;
|
| 30 |
padding: 10px;
|
| 31 |
-
|
| 32 |
border: 1px solid #ddd;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
</style>
|
| 35 |
</head>
|
| 36 |
<body>
|
| 37 |
-
<
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
</form>
|
| 48 |
-
<div class="result" id="summaryResult"></div>
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
<div class="result" id="qaResult"></div>
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
</
|
| 67 |
-
|
|
|
|
| 68 |
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
<script>
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
const
|
| 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 |
-
|
| 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 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
});
|
| 105 |
-
const result = await response.json();
|
| 106 |
-
document.getElementById(resultId).innerText = JSON.stringify(result, null, 2);
|
| 107 |
-
}
|
| 108 |
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
|
|
|
| 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>
|