Docfile commited on
Commit
61a8581
·
verified ·
1 Parent(s): 1e1800b

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +43 -14
templates/index.html CHANGED
@@ -1,29 +1,46 @@
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>Math Problem Solver</title>
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
 
 
8
  </head>
9
- <body class="bg-gray-100 p-8">
10
- <div class="container mx-auto max-w-2xl bg-white p-8 rounded-lg shadow-md">
11
- <h1 class="text-3xl font-bold mb-6 text-center">Math Problem Solver</h1>
12
 
13
- <form id="problemForm" class="space-y-4">
14
- <input type="file" id="imageInput" accept="image/*" class="w-full p-2 border border-gray-300 rounded-md">
15
- <button type="submit" class="w-full bg-blue-500 text-white p-2 rounded-md hover:bg-blue-700">Solve</button>
 
 
 
 
 
 
 
 
 
16
  </form>
17
 
18
- <div id="solution" class="mt-6 hidden">
19
- <h2 class="text-2xl font-semibold mb-4">Solution</h2>
20
- <div id="thoughts" class="p-4 border border-gray-300 rounded-md mb-4">
21
- <h3 class="font-bold mb-2">Thoughts:</h3>
22
- <pre id="thoughtsContent" class="whitespace-pre-wrap"></pre>
23
- </div>
 
 
 
 
 
 
24
  <div id="answer" class="p-4 border border-gray-300 rounded-md">
25
  <h3 class="font-bold mb-2">Answer:</h3>
26
- <pre id="answerContent" class="whitespace-pre-wrap"></pre>
27
  </div>
28
  </div>
29
  </div>
@@ -34,6 +51,7 @@
34
  const solutionDiv = document.getElementById('solution');
35
  const thoughtsContent = document.getElementById('thoughtsContent');
36
  const answerContent = document.getElementById('answerContent');
 
37
 
38
  form.addEventListener('submit', async (event) => {
39
  event.preventDefault();
@@ -46,6 +64,10 @@
46
  const formData = new FormData();
47
  formData.append('image', file);
48
 
 
 
 
 
49
  try {
50
  const response = await fetch('/solve', {
51
  method: 'POST',
@@ -56,6 +78,10 @@
56
  if (response.ok) {
57
  thoughtsContent.textContent = data.thoughts;
58
  answerContent.textContent = data.answer;
 
 
 
 
59
  solutionDiv.classList.remove('hidden');
60
  } else {
61
  alert('Error: ' + data.error);
@@ -63,6 +89,9 @@
63
  } catch (error) {
64
  console.error('Error:', error);
65
  alert('An error occurred while processing the request.');
 
 
 
66
  }
67
  });
68
  </script>
 
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>Math Problem Solver</title>
7
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
8
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
9
+ <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
10
  </head>
11
+ <body class="bg-gray-100 p-8 font-sans">
12
+ <div class="container mx-auto max-w-4xl bg-white p-8 rounded-lg shadow-lg">
13
+ <h1 class="text-4xl font-bold mb-6 text-center text-blue-700">Math Problem Solver</h1>
14
 
15
+ <form id="problemForm" class="space-y-6">
16
+ <div class="flex items-center justify-center w-full">
17
+ <label for="imageInput" class="flex flex-col items-center justify-center w-full h-64 border-2 border-blue-300 border-dashed rounded-lg cursor-pointer bg-blue-50 hover:bg-blue-100 hover:border-blue-400">
18
+ <div class="flex flex-col items-center justify-center pt-5 pb-6">
19
+ <svg aria-hidden="true" class="w-10 h-10 mb-3 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path></svg>
20
+ <p class="mb-2 text-sm text-blue-500"><span class="font-semibold">Click to upload</span> or drag and drop</p>
21
+ <p class="text-xs text-blue-500">PNG, JPG, or JPEG</p>
22
+ </div>
23
+ <input id="imageInput" type="file" accept="image/*" class="hidden" />
24
+ </label>
25
+ </div>
26
+ <button type="submit" class="w-full bg-blue-600 text-white font-bold py-3 px-6 rounded-lg hover:bg-blue-800 transition duration-300 ease-in-out">Solve</button>
27
  </form>
28
 
29
+ <div id="loader" class="hidden flex justify-center mt-6">
30
+ <div class="animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-blue-500"></div>
31
+ </div>
32
+
33
+ <div id="solution" class="mt-8 hidden">
34
+ <h2 class="text-2xl font-semibold mb-4 text-center">Solution</h2>
35
+ <details class="mb-4 border border-gray-300 rounded-md">
36
+ <summary class="p-4 cursor-pointer font-bold bg-gray-100 hover:bg-gray-200">Show/Hide Thoughts</summary>
37
+ <div id="thoughts" class="p-4">
38
+ <pre id="thoughtsContent" class="whitespace-pre-wrap font-mono"></pre>
39
+ </div>
40
+ </details>
41
  <div id="answer" class="p-4 border border-gray-300 rounded-md">
42
  <h3 class="font-bold mb-2">Answer:</h3>
43
+ <pre id="answerContent" class="whitespace-pre-wrap font-mono"></pre>
44
  </div>
45
  </div>
46
  </div>
 
51
  const solutionDiv = document.getElementById('solution');
52
  const thoughtsContent = document.getElementById('thoughtsContent');
53
  const answerContent = document.getElementById('answerContent');
54
+ const loader = document.getElementById('loader');
55
 
56
  form.addEventListener('submit', async (event) => {
57
  event.preventDefault();
 
64
  const formData = new FormData();
65
  formData.append('image', file);
66
 
67
+ // Afficher le loader et cacher la solution précédente
68
+ loader.classList.remove('hidden');
69
+ solutionDiv.classList.add('hidden');
70
+
71
  try {
72
  const response = await fetch('/solve', {
73
  method: 'POST',
 
78
  if (response.ok) {
79
  thoughtsContent.textContent = data.thoughts;
80
  answerContent.textContent = data.answer;
81
+
82
+ // Recharger MathJax pour le nouveau contenu
83
+ MathJax.typesetPromise();
84
+
85
  solutionDiv.classList.remove('hidden');
86
  } else {
87
  alert('Error: ' + data.error);
 
89
  } catch (error) {
90
  console.error('Error:', error);
91
  alert('An error occurred while processing the request.');
92
+ } finally {
93
+ // Cacher le loader
94
+ loader.classList.add('hidden');
95
  }
96
  });
97
  </script>