Update index.html
Browse files- index.html +118 -19
index.html
CHANGED
@@ -1,19 +1,118 @@
|
|
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>Nano Banana Image Edit</title>
|
7 |
+
|
8 |
+
<!-- Meta tags untuk mencegah caching halaman HTML -->
|
9 |
+
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
10 |
+
<meta http-equiv="Pragma" content="no-cache">
|
11 |
+
<meta http-equiv="Expires" content="0">
|
12 |
+
|
13 |
+
<style>
|
14 |
+
html, body {
|
15 |
+
margin: 0;
|
16 |
+
padding: 0;
|
17 |
+
width: 100%;
|
18 |
+
height: 100%;
|
19 |
+
}
|
20 |
+
#loading {
|
21 |
+
position: fixed;
|
22 |
+
top: 0;
|
23 |
+
left: 0;
|
24 |
+
width: 100%;
|
25 |
+
height: 100%;
|
26 |
+
background: rgba(255, 255, 255, 0.8);
|
27 |
+
display: flex;
|
28 |
+
justify-content: center;
|
29 |
+
align-items: center;
|
30 |
+
font-size: 24px;
|
31 |
+
z-index: 1000;
|
32 |
+
}
|
33 |
+
iframe {
|
34 |
+
width: 100%;
|
35 |
+
height: 100vh;
|
36 |
+
border: none;
|
37 |
+
}
|
38 |
+
</style>
|
39 |
+
</head>
|
40 |
+
<body>
|
41 |
+
<div id="loading">Please wait Memilih server optimal...</div>
|
42 |
+
<iframe id="streamlit-frame"></iframe>
|
43 |
+
|
44 |
+
<script>
|
45 |
+
// Ganti ini dengan versi baru setiap kali Anda update link SERVERS (misalnya "v2", "v3", dll.)
|
46 |
+
const VERSION = "v4"; // Ubah ini ke nilai baru untuk memaksa update (contoh: "v2" saat link berubah)
|
47 |
+
|
48 |
+
// Array server dengan link baru Anda (ganti sesuai kebutuhan)
|
49 |
+
const SERVERS = [
|
50 |
+
"https://nano-banana-2wjydywo9spg63qpcwzd6h.streamlit.app/?embed=true", // Ganti dengan link baru
|
51 |
+
|
52 |
+
];
|
53 |
+
|
54 |
+
// Fungsi untuk mengecek kecepatan respons server (sama seperti sebelumnya, tapi tambah timeout)
|
55 |
+
async function checkServerSpeed(url) {
|
56 |
+
const start = performance.now();
|
57 |
+
try {
|
58 |
+
const response = await Promise.race([
|
59 |
+
fetch(url, { method: 'HEAD', mode: 'no-cors' }),
|
60 |
+
new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 5000)) // Timeout 5 detik
|
61 |
+
]);
|
62 |
+
const end = performance.now();
|
63 |
+
return end - start;
|
64 |
+
} catch (error) {
|
65 |
+
console.error(`Error checking ${url}:`, error);
|
66 |
+
return Infinity;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
// Fungsi untuk memilih server berdasarkan kecepatan respons
|
71 |
+
async function chooseServer() {
|
72 |
+
const speeds = await Promise.all(SERVERS.map(checkServerSpeed));
|
73 |
+
const fastestIndex = speeds.indexOf(Math.min(...speeds));
|
74 |
+
return SERVERS[fastestIndex];
|
75 |
+
}
|
76 |
+
|
77 |
+
// Fungsi untuk memuat Streamlit
|
78 |
+
async function loadStreamlit() {
|
79 |
+
const loadingElement = document.getElementById('loading');
|
80 |
+
const iframe = document.getElementById('streamlit-frame');
|
81 |
+
|
82 |
+
// Gunakan key sessionStorage dengan VERSION untuk cache busting
|
83 |
+
const storageKey = `streamlitUrl_${VERSION}`;
|
84 |
+
let chosenUrl = sessionStorage.getItem(storageKey);
|
85 |
+
|
86 |
+
if (!chosenUrl) {
|
87 |
+
// Jika belum ada atau version berubah, pilih server baru dan simpan
|
88 |
+
chosenUrl = await chooseServer();
|
89 |
+
sessionStorage.setItem(storageKey, chosenUrl);
|
90 |
+
}
|
91 |
+
|
92 |
+
// Tambahkan cache busting ke URL iframe (timestamp unik)
|
93 |
+
const cacheBuster = new Date().getTime(); // Timestamp untuk memaksa no-cache
|
94 |
+
const iframeSrc = `${chosenUrl}&cb=${cacheBuster}`; // Append ?cb=timestamp jika URL sudah punya query
|
95 |
+
|
96 |
+
// Set src iframe
|
97 |
+
iframe.src = iframeSrc;
|
98 |
+
|
99 |
+
// Event onload untuk sembunyikan loading
|
100 |
+
iframe.onload = () => {
|
101 |
+
loadingElement.style.display = 'none';
|
102 |
+
};
|
103 |
+
|
104 |
+
// Fallback: Jika iframe gagal load (misalnya URL lama invalid), pilih ulang
|
105 |
+
iframe.onerror = async () => {
|
106 |
+
console.warn('Iframe load failed, rechoosing server...');
|
107 |
+
sessionStorage.removeItem(storageKey); // Hapus storage lama
|
108 |
+
chosenUrl = await chooseServer();
|
109 |
+
sessionStorage.setItem(storageKey, chosenUrl);
|
110 |
+
iframe.src = `${chosenUrl}&cb=${new Date().getTime()}`;
|
111 |
+
};
|
112 |
+
}
|
113 |
+
|
114 |
+
// Jalankan loadStreamlit saat halaman dimuat
|
115 |
+
window.onload = loadStreamlit;
|
116 |
+
</script>
|
117 |
+
</body>
|
118 |
+
</html>
|