Spaces:
Runtime error
Runtime error
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>AI Web Application</title> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| margin: 20px; | |
| padding: 0; | |
| background-color: #f4f4f9; | |
| color: #333; | |
| } | |
| h1 { | |
| text-align: center; | |
| color: #444; | |
| } | |
| h2 { | |
| color: #555; | |
| border-bottom: 2px solid #ddd; | |
| padding-bottom: 5px; | |
| } | |
| form { | |
| background: #fff; | |
| padding: 20px; | |
| border-radius: 8px; | |
| box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); | |
| margin-bottom: 20px; | |
| } | |
| input[type="file"], textarea, input[type="text"] { | |
| width: 100%; | |
| padding: 10px; | |
| margin: 10px 0; | |
| border: 1px solid #ddd; | |
| border-radius: 4px; | |
| font-size: 16px; | |
| } | |
| button { | |
| background-color: #007bff; | |
| color: white; | |
| border: none; | |
| padding: 10px 20px; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| font-size: 16px; | |
| } | |
| button:hover { | |
| background-color: #0056b3; | |
| } | |
| .result { | |
| background: #e9ecef; | |
| padding: 15px; | |
| border-radius: 4px; | |
| margin-top: 10px; | |
| font-family: monospace; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>AI Web Application</h1> | |
| <!-- Summarizationnnnnnnnnnnnnnnnn-> | |
| <h2>Summarization</h2> | |
| <form id="summarizeForm"> | |
| <input type="file" name="file" accept=".pdf,.docx"> | |
| <textarea name="text" placeholder="Or enter text manually"></textarea> | |
| <button type="button" onclick="submitForm('/summarize', 'summarizeForm', 'summarizeResult')">Summarize</button> | |
| </form> | |
| <div id="summarizeResult" class="result"></div> | |
| <!-- Image Captioning --> | |
| <h2>Image Captioning</h2> | |
| <form id="captionForm"> | |
| <input type="file" name="file" accept="image/*"> | |
| <button type="button" onclick="submitForm('/caption', 'captionForm', 'captionResult')">Generate Caption</button> | |
| </form> | |
| <div id="captionResult" class="result"></div> | |
| <!-- Question Answering --> | |
| <h2>Question Answering</h2> | |
| <form id="answerForm"> | |
| <input type="file" name="file" accept=".pdf,.docx"> | |
| <textarea name="text" placeholder="Or enter text manually"></textarea> | |
| <input type="text" name="question" placeholder="Enter your question"> | |
| <button type="button" onclick="submitForm('/answer', 'answerForm', 'answerResult')">Answer</button> | |
| </form> | |
| <div id="answerResult" class="result"></div> | |
| <!-- Visual Question Answering --> | |
| <h2>Visual Question Answering</h2> | |
| <form id="vqaForm"> | |
| <input type="file" name="file" accept="image/*"> | |
| <input type="text" name="question" placeholder="Enter your question"> | |
| <button type="button" onclick="submitForm('/vqa', 'vqaForm', 'vqaResult')">Answer</button> | |
| </form> | |
| <div id="vqaResult" class="result"></div> | |
| <!-- Data Visualization --> | |
| <h2>Data Visualization</h2> | |
| <form id="visualizeForm"> | |
| <input type="file" name="file" accept=".xlsx,.xls"> | |
| <input type="text" name="request" placeholder="Enter visualization request (e.g., bar, line)"> | |
| <button type="button" onclick="submitForm('/visualize', 'visualizeForm', 'visualizeResult')">Generate Code</button> | |
| </form> | |
| <div id="visualizeResult" class="result"></div> | |
| <!-- Document Translation --> | |
| <h2>Document Translation</h2> | |
| <form id="translateForm"> | |
| <input type="file" name="file" accept=".pdf,.docx"> | |
| <input type="text" name="target_language" placeholder="Enter target language (e.g., fr, es)"> | |
| <button type="button" onclick="submitForm('/translate', 'translateForm', 'translateResult')">Translate</button> | |
| </form> | |
| <div id="translateResult" class="result"></div> | |
| <script> | |
| async function submitForm(endpoint, formId, resultId) { | |
| const form = document.getElementById(formId); | |
| const formData = new FormData(form); | |
| const resultDiv = document.getElementById(resultId); | |
| resultDiv.innerHTML = "Processing..."; | |
| try { | |
| const response = await fetch(endpoint, { | |
| method: 'POST', | |
| body: formData | |
| }); | |
| if (!response.ok) { | |
| throw new Error(`HTTP error! Status: ${response.status}`); | |
| } | |
| const data = await response.json(); | |
| resultDiv.innerHTML = `<pre>${JSON.stringify(data, null, 2)}</pre>`; | |
| } catch (error) { | |
| resultDiv.innerHTML = `Error: ${error.message}`; | |
| } | |
| } | |
| </script> | |
| </body> | |
| </html> |