gsstec commited on
Commit
e736592
·
verified ·
1 Parent(s): 77e34fc

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. templates/index.html +23 -8
templates/index.html CHANGED
@@ -15,19 +15,34 @@
15
  <input type="number" id="year" placeholder="Enter Year (e.g. 2026)" value="2026">
16
  <br>
17
  <button onclick="runTechModal()">START PREDICTION</button>
18
- <div id="results" style="margin-top: 20px;"></div>
19
  </div>
20
 
21
  <script>
22
  async function runTechModal() {
23
  const year = document.getElementById('year').value;
24
- const res = await fetch('/predict', {
25
- method: 'POST',
26
- headers: {'Content-Type': 'application/json'},
27
- body: JSON.stringify({year: year})
28
- });
29
- const data = await res.json();
30
- document.getElementById('results').innerText = `Tech Score: ${data.tech_maturity_score.toFixed(4)} | Status: ${data.status}`;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
  </script>
33
  </body>
 
15
  <input type="number" id="year" placeholder="Enter Year (e.g. 2026)" value="2026">
16
  <br>
17
  <button onclick="runTechModal()">START PREDICTION</button>
18
+ <div id="results" style="margin-top: 20px; text-align: left; max-width: 300px;"></div>
19
  </div>
20
 
21
  <script>
22
  async function runTechModal() {
23
  const year = document.getElementById('year').value;
24
+ try {
25
+ const res = await fetch('/predict', {
26
+ method: 'POST',
27
+ headers: {'Content-Type': 'application/json'},
28
+ body: JSON.stringify({year: year})
29
+ });
30
+ const data = await res.json();
31
+
32
+ if (data.tech_scores) {
33
+ // Display all tech scores
34
+ let resultsHtml = '<h3>Tech Scores:</h3>';
35
+ Object.entries(data.tech_scores).forEach(([category, score]) => {
36
+ resultsHtml += `<div>${category}: ${(score || 0).toFixed(4)}</div>`;
37
+ });
38
+ resultsHtml += `<div style="margin-top: 10px;">Status: ${data.status}</div>`;
39
+ document.getElementById('results').innerHTML = resultsHtml;
40
+ } else {
41
+ document.getElementById('results').innerText = `Error: Unexpected response format`;
42
+ }
43
+ } catch (error) {
44
+ document.getElementById('results').innerText = `Error: ${error.message}`;
45
+ }
46
  }
47
  </script>
48
  </body>