Spaces:
Sleeping
Sleeping
Download templates/result.html from Mohamed-Riyaz/OCR: direct link, hf CLI and curl.
- Browser
- Download file 7.22 kB
-
https://huggingface.co/spaces/Mohamed-Riyaz/OCR/resolve/main/templates/result.html
- Command line
-
hf download hf://spaces/Mohamed-Riyaz/OCR/templates/result.html
-
curl -L -o result.html https://huggingface.co/spaces/Mohamed-Riyaz/OCR/resolve/main/templates/result.html
7.22 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>OCR Result</title> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| body { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| min-height: 100vh; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| padding: 20px; | |
| } | |
| .container { | |
| background: white; | |
| border-radius: 20px; | |
| padding: 40px; | |
| max-width: 800px; | |
| width: 100%; | |
| box-shadow: 0 20px 60px rgba(0,0,0,0.3); | |
| } | |
| h1 { | |
| color: #333; | |
| margin-bottom: 10px; | |
| font-size: 2em; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .stats { | |
| color: #666; | |
| margin-bottom: 25px; | |
| font-size: 0.95em; | |
| display: flex; | |
| gap: 20px; | |
| flex-wrap: wrap; | |
| } | |
| .stats span { | |
| background: #f0f2ff; | |
| padding: 5px 15px; | |
| border-radius: 20px; | |
| } | |
| .result-box { | |
| background: #f8f9fa; | |
| border-radius: 12px; | |
| padding: 25px; | |
| border: 2px solid #e9ecef; | |
| min-height: 200px; | |
| position: relative; | |
| } | |
| pre { | |
| white-space: pre-wrap; | |
| word-wrap: break-word; | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| font-size: 1em; | |
| line-height: 1.8; | |
| color: #333; | |
| margin: 0; | |
| } | |
| .empty-result { | |
| color: #999; | |
| font-style: italic; | |
| } | |
| .actions { | |
| margin-top: 25px; | |
| display: flex; | |
| gap: 15px; | |
| flex-wrap: wrap; | |
| } | |
| .btn { | |
| padding: 12px 30px; | |
| border: none; | |
| border-radius: 50px; | |
| font-size: 1em; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| text-decoration: none; | |
| display: inline-block; | |
| font-weight: 600; | |
| } | |
| .btn-primary { | |
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| color: white; | |
| } | |
| .btn-primary:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4); | |
| } | |
| .btn-secondary { | |
| background: #e9ecef; | |
| color: #333; | |
| } | |
| .btn-secondary:hover { | |
| background: #dee2e6; | |
| transform: translateY(-2px); | |
| } | |
| .btn-success { | |
| background: #28a745; | |
| color: white; | |
| } | |
| .btn-success:hover { | |
| background: #218838; | |
| transform: translateY(-2px); | |
| } | |
| .toast { | |
| position: fixed; | |
| bottom: 20px; | |
| right: 20px; | |
| background: #28a745; | |
| color: white; | |
| padding: 15px 25px; | |
| border-radius: 10px; | |
| box-shadow: 0 4px 15px rgba(0,0,0,0.2); | |
| transform: translateY(100px); | |
| opacity: 0; | |
| transition: all 0.3s ease; | |
| } | |
| .toast.show { | |
| transform: translateY(0); | |
| opacity: 1; | |
| } | |
| @media (max-width: 600px) { | |
| .container { | |
| padding: 20px; | |
| } | |
| .actions { | |
| flex-direction: column; | |
| } | |
| .btn { | |
| text-align: center; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>π Extracted Text</h1> | |
| <div class="stats"> | |
| <span id="charCount">Characters: 0</span> | |
| <span id="wordCount">Words: 0</span> | |
| </div> | |
| <div class="result-box"> | |
| <pre id="textDisplay">{% if text %}{{ text }}{% else %}<span class="empty-result">No text detected in the image. Please try another image.</span>{% endif %}</pre> | |
| </div> | |
| <div class="actions"> | |
| <a href="/" class="btn btn-primary">π€ Upload Another</a> | |
| <button class="btn btn-success" onclick="copyText()">π Copy to Clipboard</button> | |
| <button class="btn btn-secondary" onclick="downloadText()">πΎ Download as TXT</button> | |
| </div> | |
| </div> | |
| <div class="toast" id="toast">β Copied to clipboard!</div> | |
| <script> | |
| const textElement = document.getElementById('textDisplay'); | |
| const text = textElement.textContent.trim(); | |
| // Update character and word count | |
| if (text && text !== 'No text detected in the image. Please try another image.') { | |
| document.getElementById('charCount').textContent = `Characters: ${text.length}`; | |
| document.getElementById('wordCount').textContent = `Words: ${text.split(/\s+/).filter(w => w).length}`; | |
| } | |
| // Copy to clipboard | |
| function copyText() { | |
| const textToCopy = textElement.textContent; | |
| if (textToCopy && textToCopy !== 'No text detected in the image. Please try another image.') { | |
| navigator.clipboard.writeText(textToCopy).then(() => { | |
| showToast(); | |
| }).catch(() => { | |
| // Fallback for older browsers | |
| const textarea = document.createElement('textarea'); | |
| textarea.value = textToCopy; | |
| document.body.appendChild(textarea); | |
| textarea.select(); | |
| document.execCommand('copy'); | |
| document.body.removeChild(textarea); | |
| showToast(); | |
| }); | |
| } | |
| } | |
| function showToast() { | |
| const toast = document.getElementById('toast'); | |
| toast.classList.add('show'); | |
| setTimeout(() => { | |
| toast.classList.remove('show'); | |
| }, 2000); | |
| } | |
| // Download as .txt file | |
| function downloadText() { | |
| const textToDownload = textElement.textContent; | |
| if (textToDownload && textToDownload !== 'No text detected in the image. Please try another image.') { | |
| const blob = new Blob([textToDownload], { type: 'text/plain' }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement('a'); | |
| a.href = url; | |
| a.download = `extracted_text_${Date.now()}.txt`; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |
| } | |
| // Keyboard shortcuts | |
| document.addEventListener('keydown', (e) => { | |
| if ((e.ctrlKey || e.metaKey) && e.key === 'c') { | |
| // Let default copy work | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> |