my-ocr-demo / templates /index.html
gahanmakwana's picture
Updated UI and image display
e302e06
raw
history blame
1.63 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OCR App</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.0/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head>
<body>
<div class="container mt-5">
<h1>OCR Application</h1>
<!-- Form to upload file -->
<form method="post" enctype="multipart/form-data">
<div class="mb-3">
<label for="file" class="form-label">Choose a file</label>
<input type="file" class="form-control" name="file" id="file" required>
</div>
<button type="submit" class="btn btn-primary">Upload</button>
</form>
<!-- Error Message Display -->
{% if error %}
<div class="alert alert-danger mt-3" role="alert">
{{ error }}
</div>
{% endif %}
<!-- Display OCR Result -->
{% if text %}
<h3 class="mt-4">Extracted Text:</h3>
<pre>{{ text }}</pre>
{% endif %}
<!-- Display Image -->
{% if filename %}
<h4>Uploaded Image: {{ filename }}</h4>
<div class="image-preview">
<img src="{{ url_for('uploaded_file', filename=filename) }}" alt="Uploaded Image">
</div>
{% endif %}
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.0/js/bootstrap.bundle.min.js"></script>
</body>
</html>