Skip to content

Commit fc1d52f

Browse files
committed
Fix stats_server.py download - use blob fetch for cross-origin
1 parent debee8f commit fc1d52f

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

web/index.html

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,9 @@ <h2 style="color: #ff00ff; font-size: 22px; margin-bottom: 15px;">⚡ AUTO-INSTA
677677

678678
<div style="background: #1a1a2e; border: 1px solid #444; border-radius: 6px; padding: 15px; margin: 20px 0;">
679679
<p style="font-size: 13px; color: #fff; margin-bottom: 15px;">Step 1: Download the server file</p>
680-
<a href="https://raw.githubusercontent.com/Unity-Lab-AI/CORA/main/services/stats_server.py"
681-
download="stats_server.py"
682-
style="display: inline-block; background: #ff00ff; color: #000; padding: 12px 25px; border-radius: 4px; text-decoration: none; font-weight: bold; font-size: 14px;">
680+
<button onclick="downloadStatsServer()" style="background: #ff00ff; color: #000; padding: 12px 25px; border-radius: 4px; border: none; cursor: pointer; font-weight: bold; font-size: 14px;">
683681
📥 Download stats_server.py
684-
</a>
682+
</button>
685683

686684
<p style="font-size: 13px; color: #fff; margin: 20px 0 10px 0;">Step 2: Run it in a terminal</p>
687685
<code style="color: #00ff00; font-size: 14px; display: block; padding: 10px; background: #0a0a15; border-radius: 4px;">python stats_server.py</code>
@@ -2761,6 +2759,27 @@ <h1>C.O.R.A</h1>
27612759
document.getElementById('firstTimeModal').classList.add('visible');
27622760
}
27632761

2762+
async function downloadStatsServer() {
2763+
// Fetch and download stats_server.py as a file
2764+
try {
2765+
const response = await fetch('https://raw.githubusercontent.com/Unity-Lab-AI/CORA/main/services/stats_server.py');
2766+
if (!response.ok) throw new Error('Failed to fetch');
2767+
const blob = await response.blob();
2768+
const url = window.URL.createObjectURL(blob);
2769+
const a = document.createElement('a');
2770+
a.href = url;
2771+
a.download = 'stats_server.py';
2772+
document.body.appendChild(a);
2773+
a.click();
2774+
document.body.removeChild(a);
2775+
window.URL.revokeObjectURL(url);
2776+
} catch (e) {
2777+
// Fallback: open in new tab so user can save manually
2778+
alert('Auto-download failed. Opening file in new tab - right-click and "Save As"');
2779+
window.open('https://raw.githubusercontent.com/Unity-Lab-AI/CORA/main/services/stats_server.py', '_blank');
2780+
}
2781+
}
2782+
27642783
async function runAutoInstall() {
27652784
// Switch to backend terminal view so user can see progress
27662785
const mainContent = document.getElementById('mainContent');

0 commit comments

Comments
 (0)