llamameta commited on
Commit
95ccc78
1 Parent(s): 2b1d354

Delete index.html

Browse files
Files changed (1) hide show
  1. index.html +0 -88
index.html DELETED
@@ -1,88 +0,0 @@
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://chatbot5-20jul2024-cobd9nf8yh8ard4jwpdpn2.streamlit.app/?embed=true",
41
- ];
42
-
43
- // Fungsi untuk mengecek kecepatan respons server
44
- async function checkServerSpeed(url) {
45
- const start = performance.now();
46
- try {
47
- const response = await fetch(url, { method: 'HEAD', mode: 'no-cors' });
48
- const end = performance.now();
49
- return end - start;
50
- } catch (error) {
51
- console.error(`Error checking ${url}:`, error);
52
- return Infinity;
53
- }
54
- }
55
-
56
- // Fungsi untuk memilih server berdasarkan kecepatan respons
57
- async function chooseServer() {
58
- const speeds = await Promise.all(SERVERS.map(checkServerSpeed));
59
- const fastestIndex = speeds.indexOf(Math.min(...speeds));
60
- return SERVERS[fastestIndex];
61
- }
62
-
63
- // Fungsi untuk memuat Streamlit
64
- async function loadStreamlit() {
65
- const loadingElement = document.getElementById('loading');
66
- const iframe = document.getElementById('streamlit-frame');
67
-
68
- // Cek apakah sudah ada URL yang tersimpan di sessionStorage
69
- let chosenUrl = sessionStorage.getItem('streamlitUrl');
70
-
71
- if (!chosenUrl) {
72
- // Jika belum ada, pilih server dan simpan ke sessionStorage
73
- chosenUrl = await chooseServer();
74
- sessionStorage.setItem('streamlitUrl', chosenUrl);
75
- }
76
-
77
- // Tampilkan iframe dan sembunyikan loading
78
- iframe.src = chosenUrl;
79
- iframe.onload = () => {
80
- loadingElement.style.display = 'none';
81
- };
82
- }
83
-
84
- // Jalankan loadStreamlit saat halaman dimuat
85
- window.onload = loadStreamlit;
86
- </script>
87
- </body>
88
- </html>