PRANAV05092003 commited on
Commit
580a50b
·
1 Parent(s): 1bc79d6

Final Commit

Browse files
Files changed (1) hide show
  1. server.py +21 -0
server.py CHANGED
@@ -358,6 +358,7 @@ def _demo_html() -> str:
358
  </div>
359
  <textarea id=\"input\" spellcheck=\"false\" placeholder=\"Paste your Python code here...\"></textarea>
360
  <p class=\"meta\" id=\"status\">Status: ready</p>
 
361
  </div>
362
 
363
  <div class=\"cols\" style=\"margin-top: 14px\">
@@ -447,7 +448,27 @@ def _demo_html() -> str:
447
  }
448
  }
449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
450
  loadExample(1);
 
451
  document.getElementById('input').addEventListener('input', () => {
452
  if (!document.getElementById('autoSuggest').checked) {
453
  return;
 
358
  </div>
359
  <textarea id=\"input\" spellcheck=\"false\" placeholder=\"Paste your Python code here...\"></textarea>
360
  <p class=\"meta\" id=\"status\">Status: ready</p>
361
+ <p class=\"meta\" id=\"liveResults\">Live results: loading...</p>
362
  </div>
363
 
364
  <div class=\"cols\" style=\"margin-top: 14px\">
 
448
  }
449
  }
450
 
451
+ async function loadLiveResults() {
452
+ const el = document.getElementById('liveResults');
453
+ try {
454
+ const res = await fetch('/demo');
455
+ const data = await res.json();
456
+ const r = (data && data.results) ? data.results : null;
457
+ if (!res.ok || !r) {
458
+ throw new Error('demo request failed');
459
+ }
460
+ const easy = (r.easy ?? 0).toFixed(4);
461
+ const medium = (r.medium ?? 0).toFixed(4);
462
+ const hard = (r.hard ?? 0).toFixed(4);
463
+ const final = (r.final ?? 0).toFixed(4);
464
+ el.textContent = `Live results: Easy=${easy} Medium=${medium} Hard=${hard} Final=${final}`;
465
+ } catch (err) {
466
+ el.textContent = `Live results: error (${err.message || err})`;
467
+ }
468
+ }
469
+
470
  loadExample(1);
471
+ loadLiveResults();
472
  document.getElementById('input').addEventListener('input', () => {
473
  if (!document.getElementById('autoSuggest').checked) {
474
  return;