kacapower commited on
Commit
470eee0
·
verified ·
1 Parent(s): e286294

Create static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +99 -0
static/index.html ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Find & Play - Health Pair Tool</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ </head>
9
+ <body class="bg-slate-50 min-h-screen font-sans text-slate-800">
10
+
11
+ <div class="max-w-3xl mx-auto mt-10 p-6 bg-white rounded-xl shadow-lg border border-slate-200">
12
+ <h1 class="text-3xl font-bold text-blue-600 mb-2">Find & Play</h1>
13
+ <p class="text-gray-500 mb-6">Health Special Feature: Find multiple pairs at a single time.</p>
14
+
15
+ <!-- File Upload Form -->
16
+ <form id="upload-form" class="space-y-4 border-b pb-6 mb-6">
17
+ <div>
18
+ <label class="block text-sm font-medium text-gray-700 mb-1">Upload Data File (.txt, .csv)</label>
19
+ <input type="file" id="file-upload" accept=".txt,.csv" required
20
+ class="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100 border border-gray-300 rounded-md p-2">
21
+ </div>
22
+ <button type="submit"
23
+ class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-md transition duration-200">
24
+ Process File
25
+ </button>
26
+ </form>
27
+
28
+ <!-- Loading Spinner -->
29
+ <div id="loading" class="hidden text-blue-600 font-semibold mb-4">
30
+ Processing your health pairs... Please wait.
31
+ </div>
32
+
33
+ <!-- Results Section -->
34
+ <div id="result-section" class="hidden">
35
+ <h2 class="text-xl font-semibold mb-3">Extracted Pairs:</h2>
36
+ <div class="bg-gray-100 p-4 rounded-md border border-gray-300 max-h-96 overflow-y-auto mb-4">
37
+ <pre id="result-text" class="whitespace-pre-wrap text-sm text-gray-800"></pre>
38
+ </div>
39
+
40
+ <div class="flex space-x-3">
41
+ <button onclick="copyToClipboard()" class="bg-green-600 hover:bg-green-700 text-white font-semibold py-2 px-4 rounded-md transition duration-200 shadow">
42
+ 📋 Copy Response
43
+ </button>
44
+ <button onclick="downloadTxt()" class="bg-slate-800 hover:bg-slate-900 text-white font-semibold py-2 px-4 rounded-md transition duration-200 shadow">
45
+ 💾 Download as .txt
46
+ </button>
47
+ </div>
48
+ </div>
49
+ </div>
50
+
51
+ <!-- Frontend Logic -->
52
+ <script>
53
+ document.getElementById('upload-form').onsubmit = async (e) => {
54
+ e.preventDefault();
55
+ const fileInput = document.getElementById('file-upload');
56
+ if(fileInput.files.length === 0) return alert("Please select a file.");
57
+
58
+ const formData = new FormData();
59
+ formData.append("file", fileInput.files[0]);
60
+
61
+ document.getElementById('loading').classList.remove('hidden');
62
+ document.getElementById('result-section').classList.add('hidden');
63
+
64
+ try {
65
+ const response = await fetch('/api/find-pairs', {
66
+ method: 'POST',
67
+ body: formData
68
+ });
69
+ const data = await response.json();
70
+ document.getElementById('result-text').innerText = data.result;
71
+ document.getElementById('result-section').classList.remove('hidden');
72
+ } catch (error) {
73
+ alert("Error processing file. Check console for details.");
74
+ console.error(error);
75
+ } finally {
76
+ document.getElementById('loading').classList.add('hidden');
77
+ }
78
+ };
79
+
80
+ function copyToClipboard() {
81
+ const text = document.getElementById("result-text").innerText;
82
+ navigator.clipboard.writeText(text).then(() => {
83
+ alert("Copied to clipboard successfully!");
84
+ });
85
+ }
86
+
87
+ function downloadTxt() {
88
+ const text = document.getElementById("result-text").innerText;
89
+ const blob = new Blob([text], { type: "text/plain" });
90
+ const url = URL.createObjectURL(blob);
91
+ const a = document.createElement("a");
92
+ a.href = url;
93
+ a.download = "health_pairs_results.txt";
94
+ a.click();
95
+ URL.revokeObjectURL(url);
96
+ }
97
+ </script>
98
+ </body>
99
+ </html>