File size: 2,307 Bytes
6e8141b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>OCR to Markdown</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 0;
            padding: 0;
        }
        .container {
            margin-top: 50px;
        }
        .logo img {
            max-width: 200px;
            margin-bottom: 20px;
        }
        .upload-form {
            margin-top: 20px;
        }
        .button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="logo">
            <img src="logo.png" alt="Company Logo">
        </div>
        <h1>OCR to Markdown</h1>
        <form id="upload-form" class="upload-form">
            <input type="file" id="file-input" name="file" accept="image/*" required>
            <button type="submit" class="button">Convert</button>
        </form>
        <div id="download-link" style="margin-top: 20px;"></div>
    </div>

    <script>
        const form = document.getElementById("upload-form");
        form.addEventListener("submit", async (e) => {
            e.preventDefault();
            const fileInput = document.getElementById("file-input");
            const formData = new FormData();
            formData.append("file", fileInput.files[0]);

            const response = await fetch("/upload/", {
                method: "POST",
                body: formData
            });

            const result = await response.json();
            if (result.download_url) {
                document.getElementById("download-link").innerHTML = `
                    <a href="${result.download_url}" class="button" download>Download Markdown File</a>
                `;
            } else {
                document.getElementById("download-link").innerHTML = `
                    <p style="color: red;">Error: ${result.error}</p>
                `;
            }
        });
    </script>
</body>
</html>