Update index.html
Browse files- index.html +89 -19
index.html
CHANGED
|
@@ -1,19 +1,89 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>Black Forest Labs - Load Balanced Streamlit</title>
|
| 7 |
+
<style>
|
| 8 |
+
html, body {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
width: 100%;
|
| 12 |
+
height: 100%;
|
| 13 |
+
}
|
| 14 |
+
#loading {
|
| 15 |
+
position: fixed;
|
| 16 |
+
top: 0;
|
| 17 |
+
left: 0;
|
| 18 |
+
width: 100%;
|
| 19 |
+
height: 100%;
|
| 20 |
+
background: rgba(255, 255, 255, 0.8);
|
| 21 |
+
display: flex;
|
| 22 |
+
justify-content: center;
|
| 23 |
+
align-items: center;
|
| 24 |
+
font-size: 24px;
|
| 25 |
+
z-index: 1000;
|
| 26 |
+
}
|
| 27 |
+
iframe {
|
| 28 |
+
width: 100%;
|
| 29 |
+
height: 100vh;
|
| 30 |
+
border: none;
|
| 31 |
+
}
|
| 32 |
+
</style>
|
| 33 |
+
</head>
|
| 34 |
+
<body>
|
| 35 |
+
<div id="loading">Please wait Memilih server optimal...</div>
|
| 36 |
+
<iframe id="streamlit-frame"></iframe>
|
| 37 |
+
|
| 38 |
+
<script>
|
| 39 |
+
const SERVERS = [
|
| 40 |
+
"https://geminisearch-fu8l82trhp7dadkyncasdm.streamlit.app/?embed=true",
|
| 41 |
+
"https://geminisearch-fu8l82trhp7dadkyncasdm.streamlit.app/?embed=true"
|
| 42 |
+
];
|
| 43 |
+
|
| 44 |
+
// Fungsi untuk mengecek kecepatan respons server
|
| 45 |
+
async function checkServerSpeed(url) {
|
| 46 |
+
const start = performance.now();
|
| 47 |
+
try {
|
| 48 |
+
const response = await fetch(url, { method: 'HEAD', mode: 'no-cors' });
|
| 49 |
+
const end = performance.now();
|
| 50 |
+
return end - start;
|
| 51 |
+
} catch (error) {
|
| 52 |
+
console.error(`Error checking ${url}:`, error);
|
| 53 |
+
return Infinity;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// Fungsi untuk memilih server berdasarkan kecepatan respons
|
| 58 |
+
async function chooseServer() {
|
| 59 |
+
const speeds = await Promise.all(SERVERS.map(checkServerSpeed));
|
| 60 |
+
const fastestIndex = speeds.indexOf(Math.min(...speeds));
|
| 61 |
+
return SERVERS[fastestIndex];
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// Fungsi untuk memuat Streamlit
|
| 65 |
+
async function loadStreamlit() {
|
| 66 |
+
const loadingElement = document.getElementById('loading');
|
| 67 |
+
const iframe = document.getElementById('streamlit-frame');
|
| 68 |
+
|
| 69 |
+
// Cek apakah sudah ada URL yang tersimpan di sessionStorage
|
| 70 |
+
let chosenUrl = sessionStorage.getItem('streamlitUrl');
|
| 71 |
+
|
| 72 |
+
if (!chosenUrl) {
|
| 73 |
+
// Jika belum ada, pilih server dan simpan ke sessionStorage
|
| 74 |
+
chosenUrl = await chooseServer();
|
| 75 |
+
sessionStorage.setItem('streamlitUrl', chosenUrl);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// Tampilkan iframe dan sembunyikan loading
|
| 79 |
+
iframe.src = chosenUrl;
|
| 80 |
+
iframe.onload = () => {
|
| 81 |
+
loadingElement.style.display = 'none';
|
| 82 |
+
};
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// Jalankan loadStreamlit saat halaman dimuat
|
| 86 |
+
window.onload = loadStreamlit;
|
| 87 |
+
</script>
|
| 88 |
+
</body>
|
| 89 |
+
</html>
|